ubuntu安装配置mysql

第一次使用ubuntu,耽误了一个多小时,终于搞好了
首先在官网搜索mysql https://ubuntu.com/search?q=m...mysql

clipboard.png
点击第一个进去,须要注意的是下方红色区域部分sql

clipboard.png
其实上面写的路径是错误的,正确路径是/etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 本身的ip 或者 bind-address = 0.0.0.0 或者直接注释掉,我是注释掉了
改成之后记得要重启mysql
而后执行mysql -uroot -p,你会发现登陆不进去,解决办法是在配置文件中加入skip-grant-tables,保存后重启mysql,命令行输入mysql或者mysql -uroot,会进去mysql,接着执行
update mysql.user set authentication_string=password('newpass') where user='root' and Host ='localhost';
再执行:update user set plugin="mysql_native_password;;最后刷新权限:flush privileges;,而后quit;退出
进入配置文件把刚才加入的那一行“skip-grant-tables”注释或删除掉,重启mysql服务sudo service mysql restart数据库

若是须要远程链接数据库的话;进入mysql;选择数据库use mysql;,输入:ubuntu

grant all privileges on *.* to 'root'@'%' identified by 'password';
flush privileges;

重启mysql
终端输入mysql -h 服务器ip地址 -P 3306 -u root -p,若是链接不成功试试将3306去掉试试segmentfault

本文参考链接:https://www.jianshu.com/p/549...
https://help.ubuntu.com/commu...
https://segmentfault.com/a/11...
https://www.jianshu.com/p/8fc...服务器

相关文章
相关标签/搜索