下面讲讲关于mysql的管理实际运用举例,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完mysql的管理实际运用举例这篇文章你一定会有所受益。
[root@localhost ~]# mount.cifs //192.168.10.28/share /mnt
Password for root@//192.168.10.28/share:
[root@localhost ~]# cd /mnt/LNMP/
[root@localhost LNMP]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.10.tar.bz2 php-7.1.20.tar.gz
[root@localhost LNMP]# tar zxvf mysql-boost-5.7.20.tar.gz -C /opt
[root@localhost LNMP]# yum install -y \
gcc gcc-c++ \
ncurses \
ncurses-devel \
bison \
cmake
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates
useradd -s /sbin/nologin mysql
cd /mnt/LNMP
tar zxvf mysql-boost-5.7.20.tar.gz -C /opt
cd /opt/mysql-5.7.20/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
make && make install
chown -R mysql:mysql /usr/local/mysql/
vim /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysql.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
#支持的模块
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
[root@localhost mysql-5.7.20]# chown mysql:mysql /etc/my.cnf
[root@localhost mysql-5.7.20]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
[root@localhost mysql-5.7.20]# echo 'export PATH' >> /etc/profile
[root@localhost mysql-5.7.20]# source /etc/profile
[root@localhost mysql-5.7.20]# cd /usr/local/mysql/
[root@localhost mysql]# bin/mysqld \
> --initialize-insecure \
> --user=mysql \
> --basedir=/usr/local/mysql \
> --datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /lib/systemd/system/
systemctl start mysqld.service
[root@localhost mysql]# mysqladmin -u root -p password "abc123"
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost mysql]# mysql -uroot -p
Enter password:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'abc123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> create database IT;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| IT |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use IT;
Database changed
mysql> create table it (
-> 岗位类别 varchar(10) not null,
-> 姓名 varchar(5) not null,
-> 年龄 int(3) default 30,
-> 员工ID int(3) not null,
-> 学历 varchar(5) ,
-> 年限 int(2) ,
-> 薪资 int(5) not null,
-> primary key (员工ID));
Query OK, 0 rows affected (0.02 sec)
mysql> show tables;
| Tables_in_IT |
+--------------+
| it |
+--------------+
1 row in set (0.00 sec)
mysql> select * from it;
Empty set (0.02 sec)
mysql> describe it;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| 岗位类别 | varchar(10) | NO | | NULL | |
| 姓名 | varchar(5) | NO | | NULL | |
| 年龄 | int(3) | YES | | NULL | |
| 员工ID | int(3) | NO | PRI | NULL | |
| 学历 | varchar(5) | YES | | NULL | |
| 年限 | int(2) | YES | | NULL | |
| 薪资 | int(5) | NO | | NULL | |
+--------------+-------------+------+-----+---------+-------+
7 rows in set (0.02 sec)
mysql> insert into it value ('网络工程师','孙空无',27,011,'本科',3,4800);
Query OK, 1 row affected (0.00 sec)
mysql> select * from it;
+-----------------+-----------+--------+----------+--------+--------+--------+
| 岗位类别 | 姓名 | 年龄 | 员工ID | 学历 | 年限 | 薪资 |
+-----------------+-----------+--------+----------+--------+--------+--------+
| 网络工程师 | 孙空无 | 27 | 11 | 本科 | 3 | 4800 |
+-----------------+-----------+--------+----------+--------+--------+--------+
1 row in set (0.00 sec)
mysql> insert into it value ('windows工程师','周万石朋鸟',18,012,'幼本',0,666);
Query OK, 1 row affected (0.01 sec)
mysql> select * from it;
+------------------+-----------------+--------+----------+--------+--------+--------+
| 岗位类别 | 姓名 | 年龄 | 员工ID | 学历 | 年限 | 薪资 |
+------------------+-----------------+--------+----------+--------+--------+--------+
| 网络工程师 | 孙空无 | 27 | 11 | 本科 | 3 | 4800 |
| windows工程师 | 周万石朋鸟 | 18 | 12 | 幼本 | 0 | 666 |
+------------------+-----------------+--------+----------+--------+--------+--------+
2 rows in set (0.00 sec)
mysql> insert into it value ('水晶头工程师','媛媛',35,013,'小学',-1,-10000);
Query OK, 1 row affected (0.01 sec)
mysql> insert into it value ('公司厕所管理员','陈文强',55,014,'初中',5,1500);
Query OK, 1 row affected (0.00 sec)
mysql> insert into it value ('公司女性管理工程师','涛涛',20,015,'高中',10,11500);
Query OK, 1 row affected (0.01 sec)
mysql> insert into it value ('公司歌唱家兼播音编程','徐勇',20,016,'博士后',20,111500);
Query OK, 1 row affected (0.01 sec)
mysql> insert into it value ('台球编程员','泽鹏',18,017,'大专',2,8000);
Query OK, 1 row affected (0.00 sec)
mysql> select * from it;
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 岗位类别 | 姓名 | 年龄 | 员工ID | 学历 | 年限 | 薪资 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 网络工程师 | 孙空无 | 27 | 11 | 本科 | 3 | 4800 |
| windows工程师 | 周万石朋鸟 | 18 | 12 | 幼本 | 0 | 666 |
| 水晶头工程师 | 媛媛 | 35 | 13 | 小学 | -1 | -10000 |
| 公司厕所管理员 | 陈文强 | 55 | 14 | 初中 | 5 | 1500 |
| 公司女性管理工程师 | 涛涛 | 20 | 15 | 高中 | 10 | 11500 |
| 公司歌唱家兼播音编程 | 徐勇 | 20 | 16 | 博士后 | 20 | 111500 |
| 台球编程员 | 泽鹏 | 18 | 17 | 大专 | 2 | 8000 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
7 rows in set (0.00 sec)
mysql> mysql> select * from it;
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 岗位类别 | 姓名 | 年龄 | 员工ID | 学历 | 年限 | 薪资 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 网络工程师 | 孙空无 | 27 | 11 | 本科 | 3 | 4800 |
| windows工程师 | 周万石朋鸟 | 18 | 12 | 幼本 | 0 | 666 |
| 水晶头工程师 | 媛媛 | 35 | 13 | 小学 | -1 | -10000 |
| 公司厕所管理员 | 陈文强 | 55 | 14 | 初中 | 5 | 1500 |
| 公司女性管理工程师 | 涛涛 | 20 | 15 | 高中 | 10 | 11500 |
| 公司歌唱家兼播音编程 | 徐勇 | 20 | 16 | 博士后 | 20 | 111500 |
| 台球编程员 | 泽鹏 | 18 | 17 | 大专 | 2 | 8000 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
7 rows in set (0.00 sec)
mysql> update it set 岗位类别='linux工程师' where 员工ID=12;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from it;
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 岗位类别 | 姓名 | 年龄 | 员工ID | 学历 | 年限 | 薪资 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
| 网络工程师 | 孙空无 | 27 | 11 | 本科 | 3 | 4800 |
| linux工程师 | 周万石朋鸟 | 18 | 12 | 幼本 | 0 | 666 |
| 水晶头工程师 | 媛媛 | 35 | 13 | 小学 | -1 | -10000 |
| 公司厕所管理员 | 陈文强 | 55 | 14 | 初中 | 5 | 1500 |
| 公司女性管理工程师 | 涛涛 | 20 | 15 | 高中 | 10 | 11500 |
| 公司歌唱家兼播音编程 | 徐勇 | 20 | 16 | 博士后 | 20 | 111500 |
| 台球编程员 | 泽鹏 | 18 | 17 | 大专 | 2 | 8000 |
+--------------------------------+-----------------+--------+----------+-----------+--------+--------+
7 rows in set (0.00 sec)
mysql> quit
Bye
对于以上mysql的管理实际运用举例相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。