Mysql8.0安装
2022/3/25 2:22:41
本文主要是介绍Mysql8.0安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Mysql安装
安装:忘记咋安装了,反正安装的版本是8.0.25
出现了以下问题 mark一下:
- 启动失败,先去确认启动失败,查看端口起来没:
lsof -i 3306
- 如果没有,则查看mysql的状态:
service mysqld status
- 当发现启动失败,即出现
failed to start mysql
的文段, - 先重启看看:
systemctl restart mysqld.service
- 执行
journalctl -xe
查看文档。报错:
Failed to start MySQL Server. Unit mysqld.service entered failed state.
- 根据博客 :
# 修改/etc/my.cnf的datadir配置项 # 默认的是: datadir=/var/lib/mysql # 在 /var/lib/mysql创建个data目录 datadir改成 datadir=/var/lib/mysql/data
- 再次登录发现,不记得密码,具体现象如下:
[root@VM-4-17-centos etc]# sudo mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@VM-4-17-centos etc]# sudo mysql -uroot -proot mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@VM-4-17-centos etc]# sudo mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@VM-4-17-centos etc]# sudo mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@VM-4-17-centos etc]# mysqld -console --skip-grant-tables --shared-memory 2022-03-24T16:21:51.399204Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0/bin/mysqld (mysqld 8.0.25) starting as process 24925 2022-03-24T16:21:51.402833Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2022-03-24T16:21:51.402893Z 0 [ERROR] [MY-010119] [Server] Aborting 2022-03-24T16:21:51.403171Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0/bin/mysqld: Shutdown complete (mysqld 8.0.25) MySQL Community Server - GPL. [root@VM-4-17-centos etc]# mysqld 2022-03-24T16:22:05.531085Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0/bin/mysqld (mysqld 8.0.25) starting as process 24975 2022-03-24T16:22:05.534526Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 2022-03-24T16:22:05.534577Z 0 [ERROR] [MY-010119] [Server] Aborting 2022-03-24T16:22:05.534798Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0/bin/mysqld: Shutdown complete (mysqld 8.0.25) MySQL Community Server - GPL. [root@VM-4-17-centos etc]# service mysqld restart Redirecting to /bin/systemctl restart mysqld.service
再看发现Mysql8.0默认生成随机密码,然后你进去需要修改密码,先去日志找密码:
find / -name mysqld.log cd /var/log/ cat mysqld.log
根据密码登陆,然后修改密码:
# ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. alter user user() identified by '123456'; # ERROR 1819 (HY000): Your password does not satisfy the current policy requirements alter user user() identified by '?????';
修改密码完成。 成功可以登陆
其他问题
由于Mysql在有时会出现mysql.sock定位误差,会造成不连接数据库。
mac由当时的误差:
第一个变化my.cnf
位置/etc/my.cnf下一个,如果没有,那么。跟/usr/locate/mysql号/my.cnf下改动,然后拷贝到/etc下。
改动为例如以下:
[client] socket = /tmp/mysql.sock [mysqld] socket = /tmp/mysql.sock
没有[client]的话。自己加入~
这篇关于Mysql8.0安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-20部署MySQL集群教程:新手入门指南
- 2024-11-20MySQL读写分离教程:轻松入门
- 2024-11-20部署MySQL集群入门:一步一步搭建你的数据库集群
- 2024-11-19部署MySQL集群学习:入门教程
- 2024-11-19如何部署MySQL集群:新手入门教程
- 2024-11-19Mysql安装教程:新手必看的详细安装指南
- 2024-11-18Mysql安装入门:新手必读指南
- 2024-11-18MySQL事务MVCC原理入门详解
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程