安装
安装
sudo apt-get install mysql-server
#查看进程:
ps -aux |grep mysql
#查看版本:
mysql --version
登录以及密码修改
#本地登录
mysql -uroot -p
#远程登录
mysql -h 192.168.1.101 -P 3306 -uroot -p
#登录修改密码:
use mysql;
update user set authentication_string=PASSWORD('root') where user='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;
服务重启
service mysql restart
报错
1. ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’
需要修改密码
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
添加:skip-grant-tables
service mysql restart
mysql -uroot -p
#这样可以无密码登录
use mysql;
update user set authentication_string=PASSWORD('root') where user='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;
最后注释掉掉skip-grant-tables
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释:
#skip-grant-tables
service mysql restart
2. 远程连接 ERROR 2003 (HY000): Can’t connect to MySQL server on ‘192.168.101.85’ (10061)
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#将bind注释掉:
bind-address = 127.0.0.1
service mysql restart
3.远程连接: ERROR 1130 (HY000): Host ‘192.168.101.38’ is not allowed to connect to this MySQL server
mysql -uroot -p
use mysql;
select host from user where user='root';
update user set host = '%' where user ='root';
flush privileges;