安装与配置mysql

时间:2021-10-11
本文章向大家介绍安装与配置mysql,主要包括安装与配置mysql使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

安装与配置mysql

一、安装mysql

sudo apt install -y mysql-server mysql-client

二、启动mysql

sudo systemctl start mysql

sudo systemctl enable mysql

三、连接mysql

sudo mysql -u root -p

四、重置root密码

参考:https://blog.csdn.net/r527665047/article/details/107056941/
1 修改配置文件/etc/mysql/mysql.conf.d/mysqld.cnf
- sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
2 在[mysqld]下添加skip-grant-tables
3 重启mysql
sudo systemctl restart mysql
4 直接用mysql -u root -p登录即可,(密码直接回车)
5 登录后操作
1.use mysql;  
2.update user set authentication_string=password("ln122920"),plugin='mysql_native_password' where user='root';
3.flush privileges;
6 注销登录
7 将/etc/mysql/mysql.conf.d/mysqld.cnf文件中添加的内容注释
8 重新使用密码登录
mysql -u root -p

五、添加新用户

1.使用root登录mysql
mysql -u root -p
2.添加用户
create user 'web'@'localhost' identified by '123456';
3.授权
grant all privileges on *.* to web@localhost identified by '123456';

 

原文地址:https://www.cnblogs.com/roverq/p/15393600.html