Linux安装MySQL
yum安装mysql步骤:
1 [qq@localhost Desktop]$ su root //以root身份进入
Password:(默认为空)
2 [root@localhost Desktop]# yum list|grep mysql //查看yum上提供的mysql数据库可下载的版本
3 [root@localhost Desktop]# yum install -y mysql-server mysql mysql-devel //通过yum安装
4 [root@localhost Desktop]# service mysqld start //启动mysql服务 注意是mysqld
5 [root@localhost Desktop]# mysql -u root -p //登录mysql 默认是没有密码的 按回车即可
设置密码:set password for root@localhost=password("root");
6 [root@localhost Desktop]# service mysqld stop //停止mysql服务 注意是mysqld
使用:
1. [root@localhost Desktop]# service mysqld start //启动mysql服务
2. [root@localhost Desktop]# mysql -u root -p //登录mysql

[root@localhost Desktop]# mysql -u root -p 连接mysql
Enter password: 密码默认为空,按Enter即可跳过
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
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> set password for root@localhost=password("root"); 设置MySQL的登录密码
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; 显示数据库 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> use test; Database changed mysql> show tables; Empty set (0.01 sec) mysql> create table student(id int primary key auto_increment,name varchar(20),sex varchar(4)); 创建一个Student学生表 Query OK, 0 rows affected (0.02 sec) mysql> insert into student values(1,'白展堂','男'); 插入学生信息 Query OK, 1 row affected (0.00 sec) mysql> select * from student; 查询Student表数据 +----+-----------+------+ | id | name | sex | +----+-----------+------+ | 1 | 白展堂 | 男 | +----+-----------+------+ 1 row in set (0.00 sec)

浙公网安备 33010602011771号