linux-mariadb
来源:互联网 发布:淘宝卖核桃需要什么证 编辑:程序博客网 时间:2024/06/01 21:07
#################mariadb####
一.安装mariadb
1.yum install mariadb-server.x86_64 -y systemctl start mariadb systemctl enable mariadb
2.查看mysql的端口是否开着,
[root@localhost ~]# netstat -antlpe |grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 27 92219 3122/mysqld
####为了安全我们需要关闭该端口
vim /etc/my.cnf
skip-networking=1
[mysqld_safe]
3.对mysql设置密码mysql_secure_installation按第一次回车后设置密码然后一直按回车直到完成。
4.登陆mysql有两种方式
方式一:mysql -uroot -p
方式二:mysql -uroot -predhat 后面直接加密码可以直接进入.
5.数据库的各种控制命令
1)MariaDB [(none)]> show databases;查看库信息如下
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
2)MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
进入mysql数据库.用use可以切换数据库
3)show tables;查看数据库中的表信息.
4)desc user;查看表的格式
5)select * from user;查看表内信息
6)select * from user where Host='127.0.0.1';查看user表内值地址为127.0.0.1的信息
7)[root@localhost ~]# mysql -uroot -p -e "show databases;"从外面直接查看数据库命令
6.创建数据库与用户表.
MariaDB [(none)]> create database westos;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use westos;
Database changed
MariaDB [westos]> create table linux (
-> username varchar(50) not null,
-> password varchar(50) not null,
-> age varchar(4) );
Query OK, 0 rows affected (0.62 sec)
MariaDB [westos]> show tables;
+------------------+
| Tables_in_westos |
+------------------+
| linux |
+------------------+
1 row in set (0.00 sec)
用户表的内部结构如下
MariaDB [westos]> desc linux;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(50) | NO | | NULL | |
| password | varchar(50) | NO | | NULL | |
| age | varchar(4) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
MariaDB [westos]> insert into linux values ('qq','123','22');
Query OK, 1 row affected (0.04 sec)
MariaDB [westos]> select * from linux where age='22';
+----------+----------+------+
| username | password | age |
+----------+----------+------+
| qin | 123 | 22 |
| qq | 123 | 22 |
+----------+----------+------+
7.修改表信息
1)MariaDB [westos]> alter table linux rename message;重命名
Query OK, 0 rows affected (0.04 sec)
MariaDB [westos]> use tables;
ERROR 1049 (42000): Unknown database 'tables'
MariaDB [westos]> use tables;
ERROR 1049 (42000): Unknown database 'tables'
MariaDB [westos]> show tables;
+------------------+
| Tables_in_westos |
+------------------+
| message |
+------------------+
1 row in set (0.00 sec)
2)alter table message add class varchar(50) after password;添加一组表信息,放在password之后
3)salter table message drop class;删除掉class
4)update linux set class='linux';更新class中的内容
5)update linux set class='java' where username='lee';更新linux中uername为lee的class为java
8.备份
root@localhost ~]# mysqldump -uroot -predhat westos >/mnt/westos.sql把数据库备份到westos.sql
MariaDB [(none)]>drop database westos;删除数据库.
[root@localhost ~]# mysql -uroot -predhat -e "create database westos;"创建westos数据库,
mysql -uroot -predhat westos </mnt/westos.sql 把原先备份的东西备份到里面
9.删除
1)delete from linux where username='lee';删掉名字为lee的那一行表信息
2)delete from linux where username='lee' and class='java';删掉名字为lee的并且class为java的那一行信息
3)drop table message;删掉表message
4)drop database westos;删掉westos数据库;
一.安装mariadb
1.yum install mariadb-server.x86_64 -y systemctl start mariadb systemctl enable mariadb
2.查看mysql的端口是否开着,
[root@localhost ~]# netstat -antlpe |grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 27 92219 3122/mysqld
####为了安全我们需要关闭该端口
vim /etc/my.cnf
skip-networking=1
[mysqld_safe]
3.对mysql设置密码mysql_secure_installation按第一次回车后设置密码然后一直按回车直到完成。
4.登陆mysql有两种方式
方式一:mysql -uroot -p
方式二:mysql -uroot -predhat 后面直接加密码可以直接进入.
5.数据库的各种控制命令
1)MariaDB [(none)]> show databases;查看库信息如下
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
2)MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
进入mysql数据库.用use可以切换数据库
3)show tables;查看数据库中的表信息.
4)desc user;查看表的格式
5)select * from user;查看表内信息
6)select * from user where Host='127.0.0.1';查看user表内值地址为127.0.0.1的信息
7)[root@localhost ~]# mysql -uroot -p -e "show databases;"从外面直接查看数据库命令
6.创建数据库与用户表.
MariaDB [(none)]> create database westos;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use westos;
Database changed
MariaDB [westos]> create table linux (
-> username varchar(50) not null,
-> password varchar(50) not null,
-> age varchar(4) );
Query OK, 0 rows affected (0.62 sec)
MariaDB [westos]> show tables;
+------------------+
| Tables_in_westos |
+------------------+
| linux |
+------------------+
1 row in set (0.00 sec)
用户表的内部结构如下
MariaDB [westos]> desc linux;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(50) | NO | | NULL | |
| password | varchar(50) | NO | | NULL | |
| age | varchar(4) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
MariaDB [westos]> insert into linux values ('qq','123','22');
Query OK, 1 row affected (0.04 sec)
MariaDB [westos]> select * from linux where age='22';
+----------+----------+------+
| username | password | age |
+----------+----------+------+
| qin | 123 | 22 |
| qq | 123 | 22 |
+----------+----------+------+
7.修改表信息
1)MariaDB [westos]> alter table linux rename message;重命名
Query OK, 0 rows affected (0.04 sec)
MariaDB [westos]> use tables;
ERROR 1049 (42000): Unknown database 'tables'
MariaDB [westos]> use tables;
ERROR 1049 (42000): Unknown database 'tables'
MariaDB [westos]> show tables;
+------------------+
| Tables_in_westos |
+------------------+
| message |
+------------------+
1 row in set (0.00 sec)
2)alter table message add class varchar(50) after password;添加一组表信息,放在password之后
3)salter table message drop class;删除掉class
4)update linux set class='linux';更新class中的内容
5)update linux set class='java' where username='lee';更新linux中uername为lee的class为java
8.备份
root@localhost ~]# mysqldump -uroot -predhat westos >/mnt/westos.sql把数据库备份到westos.sql
MariaDB [(none)]>drop database westos;删除数据库.
[root@localhost ~]# mysql -uroot -predhat -e "create database westos;"创建westos数据库,
mysql -uroot -predhat westos </mnt/westos.sql 把原先备份的东西备份到里面
9.删除
1)delete from linux where username='lee';删掉名字为lee的那一行表信息
2)delete from linux where username='lee' and class='java';删掉名字为lee的并且class为java的那一行信息
3)drop table message;删掉表message
4)drop database westos;删掉westos数据库;
阅读全文
0 0
- linux-mariadb
- [MariaDB]Linux 快速安装MariaDB
- Linux 安装MariaDB
- Linux安装mariadb新版本
- linux安装mariaDB
- Linux mysql mariadb
- Linux安装配置mariadb
- linux下安装MariaDB
- Linux 安装配置MariaDB
- linux之数据库mariadb
- linux学习之mariadb
- Linux安装MariaDB
- Linux系统mariadb管理
- linux的mariadb数据库
- linux安装mariadb
- GNU/Linux-MariaDB
- linux yum install mariadb
- Linux yum 安装MariaDB
- 字符串总结!
- 函数式编程,面向对象编程
- Go语言学习笔记 --- function
- PS中转手绘教程汇总
- 选择未来的道路?
- linux-mariadb
- 解决struts2的struts.xml没有提示的问题
- es
- hdu6112(模拟水题)
- windows的启动
- SpringSesurity4.2.3 配置详情
- Django的MVC架构(1)
- forward和redirect的本质区别
- Arya and Bran & Game of the Rows & Multiple Clocks