Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deploy MariaDB server

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This example requires the deployment of a MariaDB database server on a CentOS 7 virtual machine to complete the following tasks:

1) install mariadb-server and mariadb software packages

2) start the mariadb service, and set the startup to confirm the service status.

3) set the password of the database management user root to pwd@123

4) set the default character set to utf8 to support Chinese

Step 1: install mariadb-server and mariadb packages

Yum-y install mariadb-server mariadb / / installation

Step 2: start the mariadb service, set it to boot, and confirm the service status.

1) start the service

2) systemctl restart mariadb / / start the database service

3) set systemctl enable mariadb / / to boot automatically

View service status

Systemctl status mariadb

Check the listening port

Netstat-nl | grep: 3306

Step 3: set the password of the database management user root to pwd@123

Mysqladmin-uroot password 'pwd@123'

Step 4: set the default character set to utf8 to support Chinese

[root@svr7 ~] # vim / etc/my.cnf

After entering, press the I key to insert mode and then set the cursor behind [mysqld] enter character_set_server=utf8

Press Esc to return to the command line and press Shift+: to enter wq to save exit

[root@svr7 ~] # systemctl restart mariadb / / restart to take effect

2 case 2: using the mysql connection tool

This example requires you to use the mysql command tool to connect to the local MariaDB database server based on the results of case 1 to complete the following tasks:

1) login to manage user root

2) list which libraries are available

3) exit the MariaDB > interface and return to the Linux command line

2.2 steps

To implement this case, you need to follow these steps.

Step 1: to manage user root login

[root@svr7] # mysql-uroot-ppwd@123

Step 2: list which libraries are available

MariaDB [(none)] > SHOW DATABASES; / / lists which libraries are available

Step 3: exit the MariaDB > interface and return to the Linux command line

MariaDB [(none)] > QUIT; / / exit Management

Step 2: select the mysql library, list the tables in the library, and find the user table

Command

MariaDB [(none)] > USE mysql

MariaDB [mysql] > SHOW TABLES

Step 3: create a library named studb and confirm the result

Command

MariaDB [(mysql)] > CREATE DATABASE studb

MariaDB [(mysql)] > SHOW DATABASES

Step 4: delete the library named test and confirm the result

Command

MariaDB [mysql] > DROP DATABASE test

MariaDB [mysql] > SHOW DATABASES

Step 1: create the base table in the studb library

Command

MariaDB [mysql] > USE studb

Create a base table

MariaDB [studb] > CREATE TABLE base (student number char (13), name varchar (20), gender char (1), cell phone number char (13), correspondence address varchar (48))

Step 2: check the column settings of the table

MariaDB [(studb)] > DESC base

Step 3: enter the first three data records into table base

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110001',' Guo Jing', 'male', '13145201314', 'Peach Blossom Island')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110002',' Huangrong', 'female', '13145201413', 'Peach Blossom Island')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110003',' Huazheng', 'female', '13705666777Ma,' Mongolian Camp')

Query OK, 1 row affected (0.00 sec)

Step 4: confirm the contents of form base

MariaDB [(studb)] > SELECT FROM base

Delete all data records in the base table and confirm the result

MariaDB [studb] > DELETE FROM base

MariaDB [studb] > SELECT FROM base

Delete the entire base table and confirm the result

MariaDB [studb] > DROP TABLE base

MariaDB [studb] > SELECT * FROM base

Re-establish the base table and enter all 5 data records

MariaDB [studb] > CREATE TABLE base (student number char (13), name varchar (20), gender char (1), cell phone number char (13), correspondence address varchar (48))

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110001',' Guo Jing', 'male', '13145201314', 'Peach Blossom Island')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110002',' Huangrong', 'female', '13145201413', 'Peach Blossom Island')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110003',' Huazheng', 'female', '13705666777Ma,' Mongolian Camp')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110004',' Hong Qigong', 'male', '1388888888888', 'Taihu Bei Bei Gang General rudder')

Query OK, 1 row affected (0.01sec)

MariaDB [studb] > INSERT INTO base VALUES ('NTD2020110005',' Ouyang Feng', 'male', '1877777777777, Xiyu White Camel Villa')

Query OK, 1 row affected (0.00 sec)

MariaDB [studb] > CREATE TABLE studb.sd SELECT FROM studb.base

Query OK, 5 rows affected (0.00 sec)

Records: 5 Duplicates: 0 Warnings: 0

MariaDB [studb] > SELECT FROM studb.sd

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report