博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux Ubuntu系统完整安装MySQL步骤及配置远程主机连接
阅读量:3960 次
发布时间:2019-05-24

本文共 1987 字,大约阅读时间需要 6 分钟。

最新版通过命令安装mysql 8.0并配置远程连接

建议通过主机终端进行安装

通过命令安装mysql 建议使用清华源速度较快

$ sudo apt-get install mysql-server$ sudo apt-get isntall mysql-client$ sudo apt-get install libmysqlclient-dev

安装完毕后进行初始化配置, 设置密码

sudo mysql_secure_installation

配置项选择设置

#1VALIDATE PASSWORD PLUGIN can be used to test passwords...Press y|Y for Yes, any other key for No: N (我的选项)#2Please set the password for root here...New password: (输入密码)Re-enter new password: (重复输入)#3By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them...Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)#4Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network...Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项)#5By default, MySQL comes with a database named 'test' thatanyone can access...Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)#6Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)

到此为止MySql安装完毕, 下面开始进行远程主机连接配置.

首先用根用户进入

sudo mysql -uroot -p

这一步应该会让你输入密码 刚才设置的密码, 不行就用Ubuntu切换到root用户的密码即可.

下面这一步很重要, 因为我们安装的是MySQL8.0版本所以千万不要直接配置否则将会报1064的错误

如图所示的错误

grant all privileges on . to 报错1064问题

提示意思是不能用grant创建用户,mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,mysql8.0以后已经不支持,所以必须先创建用户,然后再授权,命令如下:

mysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';Query OK, 0 rows affected (0.48 sec)mysql> grant all privileges on *.* to 'root'@'%';Query OK, 0 rows affected (0.48 sec)

这两条语句, 第一条先创建root用户并设置密码

第二条设置root用户’%'代表可以操作所有数据库

最后还没有结束, 必须修改配置文件中的bind-address

ctrl +z 退出 mysql命令界面 sudo su 切换到Ubuntu的root用户
使用命令

sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf

找到bind-address的值修改为0.0.0.0

然后保存

保存之后使用命令

/etc/init.d/mysql restart

重启mysql服务

至此即可使用远程主机连接mysql, 完成。

转载地址:http://nilzi.baihongyu.com/

你可能感兴趣的文章
对div排序
查看>>
读写blob类型字段
查看>>
js类型转换
查看>>
spring实例化Bean理解
查看>>
Mac下配置JAVA_HOME
查看>>
fedora 安装mp3播放器插件
查看>>
赏心悦目的宏代码
查看>>
理解套接字recv(),send()
查看>>
发一个C++写的跨平台的BlockingQueue
查看>>
Linux TCP/IP协议栈剖析【体系结构篇】
查看>>
游戏开发中预防内存泄露的一些措施
查看>>
以前的文章全部移除了。
查看>>
几首歌
查看>>
蝴蝶泉边
查看>>
编码转换
查看>>
freerice
查看>>
Does your mother know
查看>>
《写出质量好软件的75条体会》暨答案ZT [转自monkyy的blog]
查看>>
关于详细设计
查看>>
POJ2838,Sliding Window(单调队列)
查看>>