Linux CentOS6.5 yum安裝mysql 5.6

Linux CentOS6.5 yum安裝mysql 5.6

1.新開的雲服務器,需要檢測系統是否自帶安裝mysql

# yum list installed | grep mysql
2.如果發現有系統自帶mysql,果斷這麼幹

# yum -y remove mysql-libs.x86_64
3.隨便在你存放文件的目錄下執行,這裏解釋一下,由於這個mysql的yum源服務器在國外,所以下載速度會比較慢,還好mysql5.6只有79M大,而mysql5.7就有182M了,所以這是我不想安裝mysql5.7的原因

# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.接着執行這句,解釋一下,這個rpm還不是mysql的安裝文件,只是兩個yum源文件,執行後,在/etc/yum.repos.d/ 這個目錄下多出mysql-community-source.repo和mysql-community.repo

# rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.這個時候,可以用yum repolist mysql這個命令查看一下是否已經有mysql可安裝文件

#yum repolist all | grep mysql
6.安裝mysql 服務器命令(一路yes):

# yum install mysql-community-server
7.安裝成功後

# service mysqld start
8.由於mysql剛剛安裝完的時候,mysql的root用戶的密碼默認是空的,所以我們需要及時用mysql的root用戶登錄(第一次回車鍵,不用輸入密碼),並修改密碼

# mysql -u root
# use mysql;
# update user set password=PASSWORD("這裏輸入root用戶密碼") where User='root';
# flush privileges; 
9.查看mysql是否自啓動,並且設置開啓自啓動命令

 

# chkconfig --list | grep mysqld
# chkconfig mysqld on
10.mysql安全設置(系統會一路問你幾個問題,看不懂複製之後翻譯,基本上一路yes):

# mysql_secure_installation
此命令出現頁面爲:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 
In order to log into MySQL to secure it, we’ll need the current 
password for the root user. If you’ve just installed MySQL, and 
you haven’t set the root password yet, the password will be blank, 
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on…
 
Setting the root password ensures that nobody can log into the MySQL 
root user without the proper authorisation. 
You already have a root password set, so you can safely answer ‘n’. 
Change the root password? [Y/n] y [設置root用戶密碼] 
New password: 
Re-enter new password: 
Password updated successfully! 
Reloading privilege tables.. 
… Success!
 
By default, a MySQL installation has an anonymous user, allowing anyone 
to log into MySQL without having to have a user account created for 
them. This is intended only for testing, and to make the installation 
go a bit smoother. You should remove them before moving into a 
production environment. 
Remove anonymous users? [Y/n] y [刪除匿名用戶] 
… Success! 
Normally, root should only be allowed to connect from ‘localhost’. This 
ensures that someone cannot guess at the root password from the network. 
Disallow root login remotely? [Y/n] n [禁止root遠程登錄] 
… skipping. 
By default, MySQL comes with a database named ‘test’ that anyone can 
access. This is also intended only for testing, and should be removed 
before moving into a production environment. 
Remove test database and access to it? [Y/n] y [刪除test數據庫] 
- Dropping test database… 
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist 
… Failed! Not critical, keep moving… 
- Removing privileges on test database… 
… Success! 
Reloading the privilege tables will ensure that all changes made so far 
will take effect immediately. 
Reload privilege tables now? [Y/n] y [刷新權限] 
… Success! 
All done! If you’ve completed all of the above steps, your MySQL 
installation should now be secure. 
Thanks for using MySQL! 
Cleaning up… 
4、授權遠程登錄 
       (1)登錄mysql數據庫 Mysql -u root -p 

(2)授權登錄 
  登錄mysql之後執行 

use mysql;
這裏的123456爲你給新增權限用戶設置的密碼,%代表所有主機,也可以具體到你的主機ip地址

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456'  
刷新權限(刷新權限後不用重啓,直接使用遠程鏈接工具測試即可)

flush privileges; 
本人使用的是Vavicat


MySql授予遠程遠程權限具體詳情請查看此篇文章 MySQL【遠程用戶】授權設置(一)
 
修改字符集爲UTF-8:
vim /etc/my.cnf
在[mysqld]部分添加:

character-set-server=utf8
在文件末尾新增[client]段,並在[client]段添加:

default-character-set=utf8
 

CentOS 6.安裝msyql 5.6參考文章:https://www.cnblogs.com/renjidong/p/7047396.html
CentOS 7.安裝msyql5.6 或者5.7參考文章:https://blog.csdn.net/z13615480737/article/details/78906551

博主原創,轉載請註明出處: https://blog.csdn.net/qq_36698956

版權聲明:博客對我來說是記憶的筆記和知識的分享~此博文爲博主原創轉載請註明出處即可~   

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章