服务器安装mysql要密码_在阿里云服务器上安装mysql及重置密码
參考鏈接:https://www.cnblogs.com/ljysy/p/10324854.html
下載與安裝MySQL:
這里采用Yum管理好了各種rpm包的依賴,能夠從指定的服務(wù)器自動(dòng)下載RPM包并且安裝,所以在安裝完成后必須要卸掉,否則會(huì)自動(dòng)更新。
1.安裝MySQL官方的yum repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.下載rpm包
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
3.安裝MySQL服務(wù)
[root@localhost ~]# yum -y install mysql-community-server
最后會(huì)出現(xiàn)個(gè)complete!
4.啟動(dòng)MySQL服務(wù)
[root@localhost ~]# systemctl start mysqld.service
看到類似下面的界面,或者以Starting MySqL server..? ?started MysqlServer..結(jié)尾的就成功啟動(dòng)了
還有幾個(gè)關(guān)于MySQL常用的命令:
重啟:systemctl restart mysqld.service
停止:systemctl stop mysqld.service
查看狀態(tài):systemctl status mysqld.service
關(guān)于登錄MySQL:
登錄命令:
[root@localhost ~]# mysql -u root -p
意思就是用root用戶登錄,然后準(zhǔn)備輸入密碼
初次登陸先 查看MySql默認(rèn)密碼
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
修改數(shù)據(jù)庫(kù)密碼
由于set password for? root @localhost=password('passwd'); 可能會(huì)報(bào)錯(cuò)
MySQL 5.7 中 Your password does not satisfy the current policy requirements.
問(wèn)題
set global validate_password_policy=0;
set global validate_password_length=4;
上面兩個(gè)命令搞定 開(kāi)始設(shè)置自己的密碼:
set password for? root @localhost=password('passwd');
一些常用命令
# 重啟MySql服務(wù)
[root@localhost~]# service mysqld restart
# 查看MySql版本
[root@localhost~]# yum repolist all |grep mysql
# 查看當(dāng)前的啟動(dòng)的 MySQL 版本
[root@localhost~]# yum repolist enabled |grep mysql
# 通過(guò)Yum來(lái)安裝MySQL,會(huì)自動(dòng)處理MySQL與其他組件的依賴關(guān)系
[root@localhost~]# yum install mysql-community-server
# 查看MySQL安裝目錄
[root@localhost~]# whereis mysql
# 啟動(dòng)MySQL服務(wù)
[root@localhost~]# systemctl start mysqld
# 查看MySQL服務(wù)狀態(tài)
[root@localhost~]# systemctl status mysqld
# 關(guān)閉MySQL服務(wù)
[root@localhost~]# systemctl stop mysqld
# 測(cè)試MySQL是否安裝成功
[root@localhost~]# mysql
# 查看MySql默認(rèn)密碼
[root@localhost~]# grep 'temporary password' /var/log/mysqld.log
# 查看所有數(shù)據(jù)庫(kù)
mysql>show databases;
# 退出登錄數(shù)據(jù)庫(kù)
mysql>exit;
# 查看所有數(shù)據(jù)庫(kù)用戶
mysql>SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的服务器安装mysql要密码_在阿里云服务器上安装mysql及重置密码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Win10系统以太网卡驱动下载安装教程(
- 下一篇: mysql odbc ado性能差异_O