[root@iZ236xzsl93Z ~]# sudo yum install MariaDB-server MariaDB-client
[root@iZ236xzsl93Z ~]# service mysql startStartingMySQL. SUCCESS!
<2>MySQL操作
【restart】开启mysql:
# service mysql start
Starting MySQL SUCCESS!
【stop】关闭mysql
# service mysql stop
【restart】重新开启mysql
# service mysql restart
[root@iZ236xzsl93Z ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
#这个留在下一个博客中解决
运行mysql,root用户 不要登陆 默认没有密码
[root@iZ236xzsl93Z init.d]# mysql
Welcome to the MariaDB monitor. Commands endwith ; or \g.
Your MariaDB connection id is3
Server version: 10.0.20-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type'help;'or'\h'for help. Type'\c'to clear the current input statement.
从mysql.user里面列出用户列表 密码
MariaDB [(none)]> SELECT user,host,password FROM mysql.user;
user
host
password
root
localhost
root
iz236xzsl93z
root
127.0.0.1
root
::1
localhost
iz236xzsl93z
MariaDB[(none)]> showgrants;
Grants for root@localhost
GRANT ALL PRIVILEGES ON . TO ‘root’@’localhost’ WITH GRANT OPTION
GRANT PROXY ON ”@’%’ TO ‘root’@’localhost’ WITH GRANT OPTION
MariaDB [test]> INSERT INTO books (Title,SeriesID,AuthorID) VALUES('The Fellowship of the Ring,1,1),
-> ('The Two Towers',1,1), ('TheReturnof the King',1,1), ('The Sum ofAll Men',2,2),
-> ('Brotherhoodof the Wolf',2,2), ('Wizardborn',2,2), ('The Hobbbit',0,1);
【select】显示test里面的全部内容
MariaDB [test]> select * from books;
BookID
Title
SeriesID
AuthorID
1
The Fellowship of the Ring
1
1
2
The Two Towers
1
1
3
The Return of the King
1
1
4
The Sum of All Men
2
2
5
Brotherhood of the Wolf
2
2
6
Wizardborn
2
2
7
The Hobbbit
0
1
【insert】插入数据
MariaDB [test]> insert into books (Title,SeriesID,AuthorID)
-> values ("Lair of Bones",2,2);
Query OK, 1 row affected (0.00 sec)
MariaDB [test]> select * from books;
BookID
Title
SeriesID
AuthorID
1
The Fellowship of the Ring
1
1
2
The Two Towers
1
1
3
The Return of the King
1
1
4
The Sum of All Men
2
2
5
Brotherhood of the Wolf
2
2
6
Wizardborn
2
2
7
The Hobbbit
0
1
8
Lair of Bones
2
2
【update】修改test里面的第七个数据update
MariaDB [test]> update books set Title = "The Hobbit"where BookID = 7;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [test]> select * from books;