<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    kxbin
    成功留給有準(zhǔn)備的人
    posts - 10,  comments - 35,  trackbacks - 0

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

    配置MySQL
    [root@sample ~]#vim /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  ← 找到這一行,在這一行的下面添加新的規(guī)則,讓MySQL的默認(rèn)編碼為UTF-8
    default-character-set = utf8 ← 添加這一行
    然后在配置文件的文尾填加如下語句:
    [mysql]
    default-character-set = utf8

    啟動(dòng)MySQL服務(wù)
    [root@sample ~]# chkconfig mysqld on  ← 設(shè)置MySQL服務(wù)隨系統(tǒng)啟動(dòng)自啟動(dòng)
    [root@sample ~]# chkconfig --list mysqld  ← 確認(rèn)MySQL自啟動(dòng) 
    mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5為on的狀態(tài)就OK
    [root@sample ~]#/etc/rc.d/init.d/mysqld start  ← 啟動(dòng)MySQL服務(wù)
    Initializing MySQL database:         [ OK ]
    Starting MySQL:              [ OK ]
    MySQL初始環(huán)境設(shè)定

    [1]為MySQL的root用戶設(shè)置密碼
    MySQL在剛剛被安裝的時(shí)候,它的root用戶是沒有被設(shè)置密碼的。首先來設(shè)置MySQL的root密碼。
    [root@sample ~]# mysql -u root  ← 用root用戶登錄MySQL服務(wù)器
    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密碼');  ← 設(shè)置root密碼
    Query OK, 0 rows affected (0.01 sec)
    mysql> set password for root@'sample.centospub.com'=password('在這里填入root密碼');  ← 設(shè)置root密碼
    Query OK, 0 rows affected (0.01 sec)只有設(shè)置了這個(gè)才可以,才可以通過數(shù)據(jù)庫來安裝網(wǎng)址


    mysql> set password for root@'xxx'=password('xxx');  ← 設(shè)置root密碼
    Query OK, 0 rows affected (0.01 sec)
    mysql> select user,host,password from mysql.user;  ← 查看用戶信息
    +------+--------------------------------+--------------------------+
    | user | host          | password     |
    +------+--------------------------------+--------------------------+
    | root | localhost        | 19b68057189b027f |  ← root密碼被設(shè)置
    | root | sample.centospub.com   | 19b68057189b027f |  ← root密碼被設(shè)置
    |    | sample.centospub.com   |          |
    |    | localhost        |          |
    +------+--------------------------------+--------------------------+
    4 rows in set (0.01 sec)
    mysql> exit  ← 退出MySQL服務(wù)器
    Bye
    然后,測(cè)試一下root密碼有沒有生效。
    [root@sample ~]# mysql -u root  ← 通過空密碼用root登錄
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  ← 出現(xiàn)此錯(cuò)誤信息說明密碼設(shè)置成功
    [root@localhost ~]# mysql -u root -h sample.centospub.com  ← 通過空密碼用root登錄
    ERROR 1045 (28000): Access denied for user 'root'@'localhost'  (using password: NO)  ← 出現(xiàn)此錯(cuò)誤信息說明密碼設(shè)置成功
    [root@sample ~]#mysql -u root -p  ← 通過密碼用root登錄
    Enter password:  ← 在這里輸入密碼
    Welcome to the MySQL monitor. Commands end with ; or \g.  ← 確認(rèn)用密碼能夠成功登錄
    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登錄
    Enter password:  ← 在這里輸入密碼
    Welcome to the MySQL monitor. Commands end with ; or \g.  ← 確認(rèn)用密碼能夠成功登錄
    Your MySQL connection id is 6 to server version: 4.1.20
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> exit  ← 退出MySQL服務(wù)器
    Bye


    [2] 刪除匿名用戶
    在MySQL剛剛被安裝后,存在用戶名、密碼為空的用戶。這使得數(shù)據(jù)庫服務(wù)器有無需密碼被登錄的可能性。為消除隱患,將匿名用戶刪除。
    [root@sample ~]# mysql -u root -p  ← 通過密碼用root登錄
    Enter password:  ← 在這里輸入密碼
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 7 to server version: 4.1.20
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> select user,host from mysql.user;  ← 查看用戶信息
    +------+----------------------------+
    | user | host         |
    +------+----------------------------+
    |   | localhost       |
    | root | localhost       |
    |   | sample.centospub.com |
    | root | sample.centospub.com  |
    +------+----------------------------+
    4 rows in set (0.02 sec)
    mysql> delete from mysql.user where user='';  ← 刪除匿名用戶
    Query OK, 2 rows affected (0.17 sec)
    mysql> select user,host from mysql.user;  ← 查看用戶信息
    +------+----------------------------+
    | user | host         |
    +------+----------------------------+
    | root | localhost      |
    | root | sample.centospub.com |
    +------+----------------------------+
    2 rows in set (0.00 sec)
    mysql> exit  ← 退出MySQL服務(wù)器
    Bye
    好了,下面都不是必須的了!
    測(cè)試MySQL

    posted on 2012-02-20 22:54 kxbin 閱讀(4845) 評(píng)論(0)  編輯  收藏 所屬分類: Linux
    你恨一個(gè)人是因?yàn)槟銗鬯荒阆矚g一個(gè)人,是因?yàn)樗砩嫌心銢]有的;你討厭一個(gè)人是因?yàn)樗砩嫌心阌械臇|西;你經(jīng)常在別人面前批評(píng)某人,其實(shí)潛意識(shí)中是想接近他。

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(5)

    隨筆檔案

    文章分類

    文章檔案

    相冊(cè)

    收藏夾

    J2EE

    java技術(shù)網(wǎng)站

    Linux

    平時(shí)常去的網(wǎng)站

    數(shù)據(jù)庫

    電影網(wǎng)站

    網(wǎng)站設(shè)計(jì)

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 国产成人精品免费直播| 亚洲精品国产手机| 国产成人免费高清激情视频| 中文字幕无码毛片免费看| 亚洲国产无线乱码在线观看 | 亚洲av成人一区二区三区观看在线 | 国产福利免费在线观看| 91精品免费久久久久久久久| a级毛片免费网站| 亚洲无线码在线一区观看| 麻豆精品国产免费观看| 国产精品亚洲专区无码WEB| 亚洲精品456在线播放| 亚洲妇熟XXXX妇色黄| 伊人久久亚洲综合| 亚洲精品无码久久久| 国产精品免费播放| 日韩精品免费一区二区三区| 欧美最猛性xxxxx免费| 一级女人18毛片免费| 8x网站免费入口在线观看| 免费精品一区二区三区第35| 免费一区二区无码东京热| 中文在线观看永久免费| 久久久无码精品亚洲日韩按摩| 免费可以看黄的视频s色| 日本h在线精品免费观看| 84pao强力永久免费高清| 99在线观看精品免费99| 日本在线免费播放| 最近免费中文字幕大全免费 | 又黄又爽一线毛片免费观看| 国产在线不卡免费播放| 久久国产美女免费观看精品| 手机看片国产免费永久| 亚洲av永久无码精品三区在线4 | 久久国产精品免费观看| 少妇人妻偷人精品免费视频| 久久综合国产乱子伦精品免费| 在线观看的免费网站无遮挡| 精品国产免费人成电影在线观看|