Linux安裝mysql5.7版本


1.linux安裝mysql5.7順序

mysqladmin –version 查看版本號

mysql5.7安裝在linux中需要先初始化

  Mysqld –initialize –user=mysql

③查看初始化密碼

 Cat /var/log/mysqld.log   @localhost后面的為初始化密碼

④啟動mysql

Systemctl start mysqld

⑤查看是否啟動成功

Systemctl status mysqld  出現綠色的running為成功

⑥登陸mysql

Mysql  -uroot -p初始化密碼

⑦修改密碼

Alter user ‘root’@’localhost’ indentified by ‘123456’;

⑧退出並測試新密碼

Quit 退出

⑨查看mysql是否為自啟動

Systemctl list-unit-files|grep mysqld

2.解決mysql中文亂碼問題

①修改配置文件 、etc/mysql.conf

②修改已經存在庫、表的字符集 

alter database mydb character set 'utf-8;

alter table mytbl convert to character set 'utf-8';

③表中存在亂碼的數據刪除或者update

3.查看user表改成列式顯示

select * from user\G;

4.客戶端(SqlYoung等)遠程連接,需要創建用戶並且授權

create user  ‘zhangsan’ identified by '123456';表示創建用戶zhangsan,密碼為123456

   但只是創建了用戶,還需要授權才能訪問相應的庫和表。

grant all privileges on *.* to root @'%' identified by '123456';

表示創建root用戶,密碼為123456,並且授予所有訪問ip(@%)、所有庫表(*.*)的訪問權限

修改user表里的操作要flush previleges 才能生效

③查看防火牆是否開啟:(5.7版本)

Systemctl list-unit-files|grep firewalld

Systemctl stop firewalld 關閉防火牆

Systemctl disable firewalld 禁止防火牆開機啟動

④如果以上都沒問題,但客戶端遠程連接時還是出現10060,10038錯誤

 可以嘗試再開放一下3306端口(netstat -talnp 查看端口,即使有3306也可嘗試此步)

(1)firewall-cmd --zone=public --add-port=3306/tcp –permanent

(2)firewall-cmd –reload

(3)重啟一下:systemctl restart mysqld

 





附件列表

     


    免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM