银河麒麟高级服务器操作系统V10 SP2 源码编译安装Mysql-5.6.37
银河麒麟高级服务器操作系统V10 SP2 源码编译安装Mysql-5.6.37
安装环境检查
检查网络
检查本机IP
# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:02:e0:88 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.112/24 brd 192.168.10.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::9959:dbda:b76f:3a70/64 scope link noprefixroute
valid_lft forever preferred_lft forever
检查本机链接网络状况
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=113 time=48.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=113 time=48.7 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=113 time=48.2 ms
检查系统版本
# uname -r
4.19.90-24.4.v2101.ky10.x86_64
检查主机名
# hostname
Kylinv10
同步主机时间
# yum -y install ntpdate #yum安装ntp
# ntpdate time1.alyun.com
# date
2022年 11月 09日 星期三 17:06:08 CST
软件准备
安装依赖关系
# mkdir /soft #创建soft目录用于存放mysql安装包
# cd /soft/ #改变当前目录
# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37.tar.gz
# tar -zxvf mysql-5.6.37.tar.gz #解压安装包
# yum install cmake autoconf wget gcc-c++ gcc ncurses-devel -y #安装依赖关系
# groupadd -g 550 mysql #创建一个mysql用户组,组ID为550
# useradd -g mysql -u 550 mysql #创建一个mysql用户,用户ID为550,并加入mysql用户组中
# id mysql
用户id=550(mysql) 组id=550(mysql) 组=550(mysql) #检查mysql用户信息
编译安装
开始安装
# cd mysql-5.6.37/ #改变当前目录到安装包目录下
# pwd
/soft/mysql-5.6.37
# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/var/run/mysql/mysqld.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
# echo $? #检查cmake执行结果,为0表示正常
0
# make && make install
# echo $?
0 #检查make执行结果,为0表示正常
# cd /usr/local/mysql #改变当前目录为mysql安装目录
# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
编译参数详解
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装路径
-DMYSQL_DATADIR=/usr/local/mysql/data \ #数据文件存放地
-DSYSCONFDIR=/etc \ #配置文件my.cnf存放地
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #支持InnoDB引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 \ #支持Memory引擎
-DMYSQL_UNIX_ADDR=/var/run/mysql/mysqld.sock \ #连接数据库socket路径
-DMYSQL_TCP_PORT=3306 \ #数据库端口号
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装支持数据库分区
-DEXTRA_CHARSETS=all \ #安装所有的字符集
-DDEFAULT_CHARSET=utf8 \ #默认字符
-DDEFAULT_COLLATION=utf8_general_ci
初始化数据库
# chown -R mysql.mysql * #为/usr/local/mysql目录下所有文件目录赋读权限
# vim /etc/my.cnf #编辑mysql配置文件
[mysql]
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld]
#skip-grant-tables
explicit_defaults_for_timestamp=true
skip-name-resolve
port = 3306
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql
max_connections = 200
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
!includedir /etc/my.cnf.d
# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --no-defaults #开始初始化
# cp ./support-files/mysql.server /etc/init.d/mysql #拷贝启动文件
# chmod +x /etc/init.d/mysql #为文件赋执行权限
# mkdir /var/lib/mysql
# mkdir /var/log/mysql/ -p
# chown -R mysql.mysql /var/log/mysql
# mkdir /var/run/mysql
# chown mysql /var/run/mysql
# chown -R mysql.mysql /var/lib/mysql/
# /etc/init.d/mysql start #启动mysql服务
Starting MySQL.Logging to '/var/log/mysql/mysql.log'.
SUCCESS! #启动成功
配置数据库
# ps aux|grep mysql #查看mysql进程
root 61297 0.0 0.0 214108 3664 pts/0 S 19:45 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/var/run/mysql/mysql.pid
mysql 61539 0.1 6.9 1307208 473488 pts/0 Sl 19:45 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysql/mysql.log --pid-file=/var/run/mysql/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 61572 0.0 0.0 213152 876 pts/0 R+ 19:49 0:00 grep mysql
# vim /etc/profile.d/mysql.sh #设置mysql环境变量
export PATH=/usr/local/mysql/bin:$PATH
# source /etc/profile
# mysql -uroot -p -h127.0.0.1
mysql> use mysql;
mysql> CREATE USER 'jiangcx'@'%' IDENTIFIED BY 'Jiangcx@1234';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON *.* TO 'jiangcx'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select User,authentication_string,Host from user;
+---------+-----------------------+-----------+
| User | authentication_string | Host |
+---------+-----------------------+-----------+
| root | | localhost |
| root | | kylinv10 |
| root | | 127.0.0.1 |
| root | | ::1 |
| | NULL | localhost |
| | NULL | kylinv10 |
| jiangcx | | % |
+---------+-----------------------+-----------+
7 rows in set (0.01 sec)