Linux中安裝卸載Mysql

1. yum install mysql-server mysql-devel mysql                      注意:(mysql-server中的mysql不是大寫csdn的BUG)

2. 啓動mysqld服務, service mysqld start

3.設置mysql帳號
    mysql安裝後默認生成兩個帳號:一個是root,未設置密碼,可以從本機登錄到mysql;另一個是匿名帳號,無帳號名、無密碼,可以從本機登錄,未提供用戶名的連接都將假定爲此帳號。


    這樣的設置存在着安全隱患,按下面的步驟進行更改。
           以root帳號連接到mysql服務器:
           mysql -u root
           如果提示找不到mysql文件,請嘗試使用絕對路徑,如本文示例爲:
           /usr/local/mysql/bin/mysql -u root
           命令成功執行後將進入到mysql命令提示符下:
           mysql>
           (以下命令均在mysql命令提示符下執行)
           改變當前數據庫爲mysql:
           use mysql
           設置從本地主機登錄的root帳號密碼:
           set password for root@localhost=password('your password');

4. 執行下面的命令使更改生效:
           flush privileges ;
           執行下面的命令退出mysql命令行:
           quit

5.驗證裝好了沒有。
  
[root@iZ25phahu3aZ sbin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use infomation_schema;
ERROR 1049 (42000): Unknown database 'infomation_schema'
mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| GLOBAL_STATUS                         |
| GLOBAL_VARIABLES                      |
| KEY_COLUMN_USAGE                      |
| PARTITIONS                            |
| PLUGINS                               |
| PROCESSLIST                           |
| PROFILING                             |
| REFERENTIAL_CONSTRAINTS               |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| SESSION_STATUS                        |
| SESSION_VARIABLES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+---------------------------------------+
28 rows in set (0.00 sec)

mysql> select * from VIEWS;
Empty set (0.01 sec)

mysql> select * from SCHEMATA;
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| NULL         | information_schema | utf8                       | utf8_general_ci        | NULL     |
| NULL         | mysql              | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | test               | latin1                     | latin1_swedish_ci      | NULL     |
+--------------+--------------------+----------------------------+------------------------+----------+
3 rows in set (0.00 sec)



卸載mysql

    yum -y remove mysql*
然後清理

數據庫目錄
         /var/lib/mysql/
配置文件
         /usr/share /mysql(mysql.server命令及配置文件)
相關命令
         /usr/bin(mysqladmin mysqldump等命令)
啓動腳本

         /etc/rc.d/init.d/(啓動腳本文件mysql的目錄)


發佈了64 篇原創文章 · 獲贊 57 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章