\1. 先檢查系統是否裝有mysql
[root@localhost ~]#yum list installed mysql*[root@localhost ~]#rpm –qa|grep mysql*
\2. 查看有沒有安裝包
[root@localhost ~]#yum list mysql*
\3. 安裝mysql客戶端
[root@localhost ~]yum install mysql
\4. 安裝mysql服務端
[root@localhost ~]#yum install mysql-server[root@localhost ~]#yum install mysql-devel
\5. 在/etc/my.cnf 文件中加入默認字符集
[root@localhost ~]#vim /etc/my.cnf
\6. 啟動或者關閉mysql服務
[root@localhost ~]#service mysqld start --啟動mysql 或者 /etc/init.d/mysqld start (關閉mysql #service mysql stop)
\7. 設置開機啟動mysql服務
[root@localhost ~]# chkconfig --add mysqld
\8. 創建root用戶 密碼為123456
mysqladmin –u root password 123456
[root@localhost ~]# mysqladmin -u root password 123456
\9. 連接mysql
[root@localhost ~]# mysql -u root -p --輸入密碼123456
\10. 設置遠程訪問權限
mysql> use mysql mysql> GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’%’IDENTIFIED BY ‘admin’ WITH GRANT OPTION; --第一個admin為用戶名,第二個admin為密碼,%表示所有的電腦都可以鏈接 mysql> flush privileges; --設置立即生效
mysql> SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user; mysql> exit; --退出mysql服務 [root@localhost ~]# vi /etc/my.cnf[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql default-character-set=utf8# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#設備地址bind-address=0.0.0.0 #設置設備地址[mysqld_safe]log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]# service mysqld start --重啟mysql服務[root@localhost ~]# mysql -u root -p --連接mysql輸入密碼mysql> show global variables like 'port'; --查看端口號 +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec)
11.使用navcat連接mysql
大功告成。。。