• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • CentOS安裝mysql

    發表于:2013-05-23來源:博客園作者:qileilove點擊數: 標簽:MySQL
    安裝MySQL。 [root@sample ~]# yum -y install mysql-server ← 安裝MySQL [root@sample ~]# yum -y install php-mysql ← 安裝php-mysql 配置MySQL [root@sample ~]#gedit /etc/my.cnf ← 編輯MySQL的配置文件 [my

      安裝MySQL。

      [root@sample ~]# yum -y install mysql-server  ← 安裝MySQL

      [root@sample ~]# yum -y install php-mysql  ← 安裝php-mysql

      配置MySQL

      [root@sample ~]#gedit /etc/my.cnf  ← 編輯MySQL的配置文件

      [mysqld]

      datadir=/var/lib/mysql

      socket=/var/lib/mysql/mysql.sock

      # Default to using old password format for compatibility with mysql 3.x

      # clients (those using the mysqlclient10 compatibility package).

      old_passwords=1  ← 找到這一行,在這一行的下面添加新的規則,讓MySQL的默認編碼為UTF-8

      default-character-set = utf8  ← 添加這一行

      然后在配置文件的文尾填加如下語句:

      [mysql]

      default-character-set = utf8

      啟動MySQL服務

      [root@sample ~]# chkconfig mysqld on  ← 設置MySQL服務隨系統啟動自啟動

      [root@sample ~]# chkconfig --list mysqld  ← 確認MySQL自啟動

      mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5為on的狀態就OK

      [root@sample ~]#/etc/rc.d/init.d/mysqld start  ← 啟動MySQL服務

      Initializing MySQL database:         [ OK ]

      Starting MySQL:              [ OK ]

      MySQL初始環境設定

      [1]為MySQL的root用戶設置密碼

      MySQL在剛剛被安裝的時候,它的root用戶是沒有被設置密碼的。首先來設置MySQL的root密碼。

      [root@sample ~]# mysql -u root  ← 用root用戶登錄MySQL服務器

      Welcome to the MySQL monitor. Commands end with ; or \g.

      Your MySQL connection id is 2 to server version: 4.1.20

      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

      mysql> select user,host,password from mysql.user;  ← 查看用戶信息

      +------+------------------------------+---------------+

      | user | host          | password |

      +------+------------------------------+---------------+

      | root | localhost        |       |  ← root密碼為空

      | root | sample.centospub.com  |       |  ← root密碼為空

      |   | sample.centospub.com |       |

      |   | localhost       |       |

      |root | % |XXX     |

      |   |     |       |

      +------+------------------------------+---------------+

      4 rows in set (0.00 sec)

      mysql> set password for root@localhost=password('在這里填入root密碼');  ← 設置root密碼

      Query OK, 0 rows affected (0.01 sec)

      mysql> set password for root@'sample.centospub.com'=password('在這里填入root密碼');  ← 設置root密碼

      Query OK, 0 rows affected (0.01 sec)

      只有設置了這個才可以,才可以通過數據庫來安裝網址

      mysql> set password for root@'xxx'=password('xxx');  ← 設置root密碼

      Query OK, 0 rows affected (0.01 sec)

      mysql> select user,host,password from mysql.user;  ← 查看用戶信息

      +------+--------------------------------+--------------------------+

      | user | host          | password     |

      +------+--------------------------------+--------------------------+

      | root | localhost        | 19b68057189b027f |  ← root密碼被設置

      | root | sample.centospub.com   | 19b68057189b027f |  ← root密碼被設置

      |    | sample.centospub.com   |          |

      |    | localhost        |          |

      +------+--------------------------------+--------------------------+

      4 rows in set (0.01 sec)

      mysql> exit  ← 退出MySQL服務器

      Bye

      然后,測試一下root密碼有沒有生效。

      [root@sample ~]# mysql -u root ← 通過空密碼用root登錄

      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  ← 出現此錯誤信息說明密碼設置成功

      [root@localhost ~]# mysql -u root -h sample.centospub.com  ← 通過空密碼用root登錄

      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  ← 出現此錯誤信息說明密碼設置成功

      [root@sample ~]#mysql -u root -p ← 通過密碼用root登錄

      Enter password:  ← 在這里輸入密碼

      Welcome to the MySQL monitor. Commands end with ; or \g.  ← 確認用密碼能夠成功登錄

      Your MySQL connection id is 5 to server version: 4.1.20

      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

      mysql> exit

      Bye

      [root@sample ~]# mysql -u root -h sample.centospub.com -p  ← 通過密碼用root登錄

    原文轉自:http://www.blogjava.net/qileilove/archive/2012/05/24/379016.html

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>