欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

centos7 中安装 mysql5.6 的过程

程序员文章站 2023-10-17 11:05:18
前提是Centos的环境是好的,并且相关的软件包已经安装好。 1、创建用户,并修改创建的数据目录的属主 2、安装需要的依赖软件 3、上传源码包,并解压安装 4、进行简单的配置文件的配置 5、进行安装初始化 执行结果: 6、启动mysql,并把相关命令添加到环境变量中 7、进行简单的mysql的用户的 ......

前提是centos的环境是好的,并且相关的软件包已经安装好。

1、创建用户,并修改创建的数据目录的属主

[root@bogon ~]# useradd -m mysql -s /sbin/nologin 
[root@bogon ~]# mkdir /data
[root@bogon ~]# chown  -r  mysql:mysql /data/

2、安装需要的依赖软件

[root@bogon ~]# yum -y install gcc gcc-c++ cmake ncurses-devel perl-data-dumper openssl-devel

3、上传源码包,并解压安装

[root@bogon ~]# tar -xf mysql-5.6.37.tar.gz -c /usr/local/src/

[root@bogon ~]# cmake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/data \
-dwith_myisam_storage_engine=1\
-dwith_innobase_storage_engine=1\
-dwith_archive_storage_engine=1\
-dwith_blackhole_storage_engine=1\
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-denabled_local_infile=1\
-ddefault_charset=utf8\
-ddefault_collation=utf8_general_ci\
-dextra_charsets=all\
-dmysql_tcp_port=3306\
-dmysql_unix_addr=/tmp/mysqld.sock\
-dwith_debug=0 \
-dwith_ssl=system

[root@bogon ~]# make && make install

4、进行简单的配置文件的配置

[root@bogon etc]# rm -rf my.cnf.d/
[root@bogon support-files]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

5、进行安装初始化

[root@bogon scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/

      执行结果:

2018-10-09 22:39:03 37118 [note] innodb: shutdown completed; log sequence number 1625977
ok

filling help tables...2018-10-09 22:39:03 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-10-09 22:39:03 0 [note] ignoring --secure-file-priv value as server is running with --bootstrap.
2018-10-09 22:39:03 0 [note] /usr/local/mysql//bin/mysqld (mysqld 5.6.37) starting as process 37140 ...
2018-10-09 22:39:03 37140 [note] innodb: using atomics to ref count buffer pool pages
2018-10-09 22:39:03 37140 [note] innodb: the innodb memory heap is disabled
2018-10-09 22:39:03 37140 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2018-10-09 22:39:03 37140 [note] innodb: memory barrier is not used
2018-10-09 22:39:03 37140 [note] innodb: compressed tables use zlib 1.2.3
2018-10-09 22:39:03 37140 [note] innodb: using cpu crc32 instructions
2018-10-09 22:39:03 37140 [note] innodb: initializing buffer pool, size = 128.0m
2018-10-09 22:39:03 37140 [note] innodb: completed initialization of buffer pool
2018-10-09 22:39:03 37140 [note] innodb: highest supported file format is barracuda.
2018-10-09 22:39:03 37140 [note] innodb: 128 rollback segment(s) are active.
2018-10-09 22:39:03 37140 [note] innodb: waiting for purge to start
2018-10-09 22:39:03 37140 [note] innodb: 5.6.37 started; log sequence number 1625977
2018-10-09 22:39:03 37140 [note] rsa private key file not found: /data//private_key.pem. some authentication plugins will not work.
2018-10-09 22:39:03 37140 [note] rsa public key file not found: /data//public_key.pem. some authentication plugins will not work.
2018-10-09 22:39:03 37140 [note] binlog end
2018-10-09 22:39:03 37140 [note] innodb: fts optimize thread exiting.
2018-10-09 22:39:03 37140 [note] innodb: starting shutdown...
2018-10-09 22:39:04 37140 [note] innodb: shutdown completed; log sequence number 1625987
ok
其中出现两个ok是成功的。

6、启动mysql,并把相关命令添加到环境变量中

初始化之后的说明:
new default config file was created as /usr/local/mysql//my.cnf and will be used by default by the server when you start it. you may edit this file to change server settings warning: default config file /etc/my.cnf exists on the system this file will be read by default by the mysql server if you do not want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the server 配置文件的问题。 [root@bogon scripts]# mysqld_safe --defaults-file=/usr/local/mysql/my.cnf & [root@bogon scripts]# ps -aux | grep -v grep | grep mysql root 37183 0.0 0.1 113308 1620 pts/0 s 22:46 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf mysql 37252 0.7 44.8 1325772 449480 pts/0 sl 22:46 0:01 /usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=bogon.err --pid-file=bogon.pid

 7、进行简单的mysql的用户的密码修改。

[root@bogon bin]# mysql -u root 
mysql> use mysql;
mysql> update user set password=password("111111") where user='root';
mysql> flush privileges;

8、停止mysql的服务

[root@bogon bin]# mysqladmin -uroot -p shutdown

9、错误

编译错误删除

[root@bogon mysql-5.6.37]# rm -rf cmakecache.txt