centos7 mysql安裝與用戶設置


1、環境:Centos 7.0 64位
2、mysql版本:5.7
3、安裝:https://dev.mysql.com/doc/refman/5.7/en/installing.html
3.1、創建mysql用戶和組:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
3.2、忘記 linux下mysql5.7 root用戶的密碼:
service mysqld stop
修改/etc/my.inf 末尾添加 skip-grant-tables
service mysqld start
use mysql
update user set authentication_string=password('Kd8k&dfdl023') where user='root';
flush privileges;

將/etc/my.inf中的skip-grant-tables 刪掉;
service mysqld restart
mysql -uroot -p
use mysql
set password=password('newpassword');
3.3、創建mysql用戶
https://dev.mysql.com/doc/refman/5.7/en/adding-users.html
mysql> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'trade'@'%' WITH GRANT OPTION;
3.5、查看mysql端口:
mysql> show variables like 'port';
3.4、打開防火牆配置文件:
關閉並禁止firewall開機啟動:
停止
systemctl stop firewalld.service
禁止開機啟動
systemctl disable firewalld.service
安裝iptables防火牆
yum install iptables-services
編輯防火牆配置文件打開指定的端口號使用udp協議打開52100端口:
vi /etc/sysconfig/iptables
保存退出
:wq
最后重啟防火牆使配置生效
systemctl restart iptables.service
設置防火牆開機啟動
systemctl enable iptables.service

3.5、查詢mysql配置文件
locate my.cnf
查看mysql默認讀取的配置列表:
mysql --help|grep 'my.cnf'
查看3306端口信息:
netstat -apn|grep 3306
修改mysql設置中的bind-address選項:
bind-address = 0.0.0.0
修改mysql設置中的port選項:
port=3308
----->使用阿里雲服務器,需額外配置阿里雲安全規則,設置入場端口!!!!!(巨坑。。)

4、創建數據庫和數據表們:見sql文件。
5、centos設置cmd為支持中文
echo $LANG
yum group list
yum install system-config-users
yum groupinstall chinese-support


5.1、linux設置mysql編碼為utf-8

6、linux 命令執行.sql文件
登錄mysql
執行 source sqlpath




免責聲明!

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



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