ubuntu18.04.1中安装mysql5.7
ubuntu18.04安装mysqlroot用户下:
~#apt install mysql-server-5.7
执行完成,查看执行成功与否:
~#echo $?
~#0(返回0表示安装没有问题)
设置密码:
查看下/etc/mysql/debain.cnf配置文件,
# Automatically generated for Debian scripts. DO NOT TOUCH!
host = localhost
user = debian-sys-maint
password = bqDQ42VIUk9zTFFR
socket = /var/run/mysqld/mysqld.sock
host = localhost
user = debian-sys-maint
password = bqDQ42VIUk9zTFFR
socket = /var/run/mysqld/mysqld.sock
用里面的debian-sys-maint用户登录数据库,密码就是password对应的bqDQ42VIUk9zTFFR
~#mysql -u debian-sys-maint -p 然后输入bqDQ42VIUk9zTFFR
就进入了mysql界面:现在可以设置mysql密码:
~#update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
注意,authentication_string是密码 ,plugin是验证方式,这两个一定要同时改。从mysql5.7开始root的默认验证方式是auth_socket
mysql> select user, plugin from mysql.user;
+-----------+-----------------------+
| user | plugin |
+-----------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| dev | mysql_native_password |
+-----------+-----------------------+
这种方式智能用系统root用户登录时才可以登录数据库的root用户。所以需要改为mysql_native_password方式,才可以不收系统用户限制。
最后不要忘了重启下mysql 服务
service mysql restart
参考博客:https://blog.csdn.net/shooke/article/details/81980676
: https://www.cnblogs.com/springsnow/p/12206227.html
页:
[1]