mysql安装

1.查看mysql的运行状态

systemctl status mysql.service

 2.安装与初始化

https://t.codebug.vip/questions-691282.htm

sudo apt install mysql-server mysql-client #同时安装服务器和客户端
sudo mysql_secure_installation

3.Error: Access denied for user 'root'@'localhost' (using password: YES)

https://blog.csdn.net/wangliyao518/article/details/83011522,根据这个来解决

vim修改只读文件:

按‘a’表示进入插入模式,修改后执行:

:w !sudo tee %

会修改只读文件。

按照如下命令解决了本问题:

vim /etc/mysql/mysql.conf.d/mysqld.cnf
//修改只读文件在最后一行添加 skip-grant-tables,并保存

 service mysql restart//重启服务

mysql -uroot -p//回车可进入mysql

use mysql;
update user set authentication_string=PASSWORD("rootadmin") where user='root';

vim /etc/mysql/mysql.conf.d/mysqld.cnf
//删除添加的最后一行 skip-grant-tables,并保存

service mysql restart
mysql -uroot -prootadmin

退出mysql使用 quit; 命令

4.尝试创建表

create database yourdb;

报错:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

根据https://blog.csdn.net/memory6364/article/details/82426052解决了:

alter user 'root'@'localhost' identified by '123456';

但要设置一个比较复杂的密码。

 

posted @ 2021-05-24 01:10  lypbendlf  阅读(45)  评论(0编辑  收藏  举报