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');
以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
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
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.
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)
+--------------------+
| 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
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> 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)
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)
然后清理
+--------------+--------------------+----------------------------+------------------------+----------+
| 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的目录)