[root@localhost app]# cd /usr/local/
[root@localhostlocal]# ls
bin etc games include lib lib64 libexec mariadb-10.2.8-linux-x86_64 sbin share src
[root@localhostlocal]# ln -s mariadb-10.2.8-linux-x86_64/ mysql ------> 创建一个硬链接
[root@localhostlocal]# ls
bin etc games include lib lib64 libexec mariadb-10.2.8-linux-x86_64 mysql sbin share src
[root@localhostlocal]# cd mysql/ ------>进入解压的目录
[root@localhost mysql]# ls
bin CREDITS include man README-wsrep sql-bench
COPYING data INSTALL-BINARY mysql-test scripts support-files
COPYING.thirdparty EXCEPTIONS-CLIENT lib README.md share
[root@localhost support-files]# cp my-huge.cnf /etc/mysql/my.cnf ------>配置文件的名字是指定的,不能随便修改
cp: cannot create regular file ‘/etc/mysql/my.cnf’: No such file or directory ------>显示没有该目录,手动创建该目录
[root@localhost support-files]# mkdir /etc/mysql
[root@localhost support-files]# cp my-huge.cnf /etc/mysql/my.cnf
[root@localhost support-files]# vim /etc/mysql/my.cnf ------> 配置文件
[mysqld] ------> 在[mysqld]下加入下面三行
datadir = /app/mysqldb ------> 这里指定的目录可以随意指定,不过后续操作需要对应上,指定数据库的数据存放文件
innodb_file_per_table = no ------> 指定数据库中每个表都是单独的文件,方便我们后续修改
skip_name_resolve = no ------> 跳过名字解析
如果我们直接使用yum安装mysql,在安装后会自动创建mysql用户,因为我们这里是编译二进制程序包,所以需要手动来创建mysql用户
[root@localhost mysql]# useradd -r -d /app/mysqldb -s /sbin/nologin -m mysql
[root@localhost mysql]# id mysql
uid=989(mysql) gid=984(mysql) groups=984(mysql)
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/app/mysqldb
Installing MariaDB/MySQL system tables in '/app/mysqldb' ...
2017-10-1416:27:55139772340328256 [Warning] option 'skip_name_resolve': boolean value 'no' wasn't recognized. Set to OFF.
2017-10-1416:27:55139772340328256 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2017-10-1416:27:58139772339738368 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
'./bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/app/mysqldb'
You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB'sstrongand vibrant community:
https://mariadb.org/get-involved/
[root@localhost mysql]# ls /app/mysqldb/
aria_log.00000001 ib_buffer_pool ib_logfile0 mysql mysql-bin.index performance_schema
aria_log_control ibdata1 ib_logfile1 mysql-bin.000001 mysql-bin.state test
以上系统数据库的文件已经创建成功,接下来我们将服务开启
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
binary-configure my-innodb-heavy-4G.cnf my-small.cnf mysql.server wsrep_notify
magic my-large.cnf mysqld_multi.server policy
my-huge.cnf my-medium.cnf mysql-log-rotate wsrep.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/
[root@localhost support-files]# chkconfig --list mysqld
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use'systemctl list-unit-files'.
To see services enabled on particular target use'systemctl list-dependencies [target]'.
service mysqld supports chkconfig, but isnot referenced in any runlevel (run 'chkconfig--add mysqld')
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig --list mysqld
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use'systemctl list-unit-files'.
To see services enabled on particular target use'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on3:on4:on5:on6:off
5、启动服务
[root@localhost support-files]# service mysqld startStarting mysqld (via systemctl):Jobfor mysqld.service failed because the control process exited with error code. See"systemctl status mysqld.service"and"journalctl -xe"for details.
[FAILED]
------> 启动服务失败,这是因为我们没有创建数据库的日志文件,手动来创建
[root@localhost support-files]# mkdir /var/log/mariadb
[root@localhost support-files]# ll /var/log/mariadb -d
drwxr-xr-x. 2 root root 6Oct1416:34 /var/log/mariadb
[root@localhost support-files]# chown mysql /var/log/mariadb
[root@localhost support-files]# ll /var/log/mariadb -d
drwxr-xr-x. 2 mysql root 6Oct1416:34 /var/log/mariadb
[root@localhost support-files]# service mysqld start Starting mysqld (via systemctl): [ OK ]
------> 开启服务成功
[root@localhost support-files]# ss -ntlStateRecv-QSend-QLocalAddress:PortPeerAddress:PortLISTEN0128 *:111 *:*LISTEN0128 *:22 *:*LISTEN0128127.0.0.1:631 *:*LISTEN0100127.0.0.1:25 *:*LISTEN080:::3306:::*LISTEN0128:::111:::*LISTEN0128:::22:::*LISTEN0128::1:631:::*LISTEN0100::1:25:::*
------> 3306端口已经打开