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');
flush privileges ;
執行下面的命令退出mysql命令行:
quit
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
affiliates. Other names may be trademarks of their respective
owners.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
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
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)
Empty set (0.01 sec)
+--------------+--------------------+----------------------------+------------------------+----------+
| 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*然後清理
/etc/rc.d/init.d/(啓動腳本文件mysql的目錄)