1. 程式人生 > >yum 安裝mysql數據庫

yum 安裝mysql數據庫

sql mysql pass 查看 連接 var 客戶 l數據庫 sql skip

  1、查看是否有安裝mysql,有的話通過yum remove mysql先卸載掉,卸載完成後執行

     yum install -y mysql-server mysql mysql-deve

  2、啟動mysql服務

     service mysqld start  //也可以通過/etc/init.d/mysqld start啟動

  3、設置為開機自啟動

     chkconfig mysqld on

  4、設置root賬號的密碼

     mysqladmin -u root password ‘newpass‘

     如果上面這種設置密碼的方式失敗還可以嘗試通過如下方式設置

      mysql -u root

      mysql> use mysql;

      mysql> UPDATE user SET Password = PASSWORD(‘newpass‘) WHERE user = ‘root‘;

      mysql> FLUSH PRIVILEGES;

   5、遠程客戶端連接授權

      mysql -u root –p     //會提示輸入密碼,輸入上面設置的root新密碼

      GRANT ALL PRIVILEGES ON *.* TO [email protected]%‘ IDENTIFIED BY ‘newpass‘ WITH GRANT OPTION  //*.*表示不對連接的ip做限制

  6、對my.cnf中的配置進行設置(文件一般在/etc/my.cnf)

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
security risks
symbolic-links=0
max_connections = 1000
default-character-set=utf8
max_allowed_packet = 16M
skip-name-resolve
event_scheduler = on

   7、重啟mysql服務

     /etc/init.d/mysqld restart

yum 安裝mysql數據庫