MySQL 8.0 安装
MySQL 8.0 安装
安装
在Ubuntu20.04上安装MySQL8.0及正确配置[已验证]
sudo apt-get update #更新源
sudo apt-get install mysql-server #安装
systemctl status mysql
远程登录
GRANT ALL ON *.* TO 'root'@'%'
update user set host = '%' where user = 'root';
update user set host = '%' where user = 'root' and host='localhost';
GRANT ALL ON *.* TO 'root'@'%'
flush privileges;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
新建用户
CREATE USER 'mycompany'@'%' IDENTIFIED BY 'mycompany';
ALTER USER 'mycompany'@'%' IDENTIFIED WITH mysql_native_password BY 'mycompany';
flush privileges;
-
MySQL8创建、删除用户和授权、消权
https://blog.csdn.net/qq_43278247/article/details/108883177
vi /etc/mysql/my.cnf
添加
[mysqld]
port=3306
bind-address=0.0.0.0
service mysql restart
异常
-
mysql 8 设置允许远程连接 You are not allowed to create a user with GRANT
https://blog.csdn.net/mxskymx/article/details/88765072 -
Your password does not satisfy the current policy requirements
https://blog.csdn.net/zhanaolu4821/article/details/93622812 -
MySQL常用语句一、连接MySQL格式:mysql-h主机地址-u用户名-p用户密
https://blog.csdn.net/weixin_44797182/article/details/90639195
- MySQL8下忘记密码后重置密码的办法(MySQL老方法不灵了),https://www.jb51.net/article/145464.htm
sudo vim /etc/my.cnf
[mysqld]
skip-grant-tables
systemctl restart mysqld
use mysql; (使用mysql数据表)
update user set authentication_string='' where user='root';(将密码置为空)
quit; (然后退出Mysql)
- Mysql8.0重置初始密码的方法, https://www.jianshu.com/p/0504cf8f7350
重新打开一个终端,第一个终端记得关闭
mysql -u root -p 不输密码直接enter,进入mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';(更改密码)
如果报错如图,输入:flush privileges;
Docker
使用Docker搭建MySQL服务
docker run -p 3306:3306 --name mysql \
-v /usr/local/docker/mysql/conf:/etc/mysql \
-v /usr/local/docker/mysql/logs:/var/log/mysql \
-v /usr/local/docker/mysql/data:/var/lib/mysql \
-v /home/mysql/mysql-files:/var/lib/mysql-files/ \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql
docker mysql mysqld: Error on realpath() on '/var/lib/mysql-files' No such file or directory
-v /home/mysql/mysql-files:/var/lib/mysql-files/

浙公网安备 33010602011771号