centos7安裝mysql

下載並安裝MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install
mysql57-community-release-el7-10.noarch.rpm(吐槽官方yum好慢!!!!)

(以後每次yum操作都會自動更新,需要在安裝完成後把這個卸載掉:yum -y remove
mysql57-community-release-el7-10.noarch)

安裝MySQL服務器

yum -y install mysql-community-server

centos7安裝mysql

啟動

systemctl start mysqld.servic

查看MySQL運行狀態

systemctl status mysqld.service

此時MySQL已經開始正常運行,不過要想進入MySQL還得先找出此時root用戶的密碼,通過如下命令可以在日誌文件中找出密碼:

grep "password" /var/log/mysqld.log
centos7安裝mysql

登錄mysql -uroot -p

password:

修改密碼:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '******';

CREATE USER 'test'@'localhost' IDENTIFIED BY '1234'; #本地登錄

CREATE USER 'test'@'%' IDENTIFIED BY '1234'; #遠程登錄

create database testDB;

alter database testDB charset uft8;

授權test用戶擁有testDB數據庫的所有權限:

grant all privileges on testDB.* to “test”@”localhost”;

flush privileges;

修改默認編碼

vi /etc/my.conf

在[mysqld]結束位置添加:character_set_server=utf8

重新啟動mysql服務。

停止命令:systemctl stop mysqld.service

啟動命令:systemctl start mysqld.service

查看字符集 show variables like 'character%';

centos7安裝mysql


分享到:


相關文章: