数据库安装mysql57_记录CentOS7.X版本下安装MySQL5.7数据库
記錄CentOS7.X版本下安裝MySQL5.7數據庫
設置rpm下載目錄在/opt目錄下新建一個目錄存放mysql
cd /opt
sudo mkdir mysql12
下載MySQL的源
如果在這之前沒有提示-bash: wget: command not found,那么還得先安裝wget
sudo yum install wget1
安裝MySQL的rpm
sudo rpm -ivh mysql57-community-release-el7-8.noarch.rpm1
安裝MySQL
sudo yum install mysql-server1
在這步中只需要一直y然后回車就行,數據庫就安裝好了,現在進行連接:
mysql -uroot -p
root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)123
這是/var/lib/mysql權限問題,修改MySQL權限為當前用戶
sudo chown -R xxx:xxx /var/lib/mysql1
xxx為當前的用戶名以及所屬組
重啟MySQL服務
service mysqld restart1
密碼輸入root即可
如果還不行的話通過這個命令獲得初始密碼
cat /var/log/mysqld.log | grep password1
其中A temporary password is generated for root@localhost: bGlY?13TtFyX–:后面的就是初始密碼;登陸進去之后先不做其他操作,作如下操作:
set global validate_password_policy=0;
set global validate_password_length=4;12
設置密碼
alter user 'root'@'localhost' identified by 'root';1
自此CentOS安裝MySQL5.7就完美安裝了
mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
總結
以上是生活随笔為你收集整理的数据库安装mysql57_记录CentOS7.X版本下安装MySQL5.7数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql数据库整体备份和恢复_MySQ
- 下一篇: 《2023循环时尚行业趋势报告》:预期至