mysql源码安装
官网上下载cmake-2.8.12.2-4.el6.x86_64.rpm mysql-boost-5.7.17.tar.gz
因为企业6版本自带的cmake版本过低,所以应该官网下载2.8以上版本
yum install -y cmake-2.8.12.2-4.el6.x86_64.rpm
tar zxf mysql-boost-5.7.17.tar.gz
cd mysql-5.7.17/
cmake并添加常用的模块
[root@server7 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \
> -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \
> -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all
错误:没有gcc、gcc-c++
yum install -y gcc gcc-c++
rm -f CMakeCache.txt #删除cmake的缓存,不然不会识别刚下载的服务
cmake再来一次
错误:没有boost路径
[root@server7 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/
错误:没有安装ncurses-devel
yum install -y ncurses-devel
rm -f CMakeCache.txt
警告:没有biso
yum install -y bison
rm -f CMakeCache.txt
cmake 再来一次
make
make install
配置mysql文件
cd /usr/local/lnmp/mysql/support-files/
cp my-default.cnf /etc/my.cnf
vim /etc/my.cnf
# These are commonly set, remove the # and set as required.
basedir = /usr/local/lnmp/mysql
datadir = /usr/local/lnmp/mysql/data
port = 3306
# server_id = .....
socket = /usr/local/lnmp/mysql/data/mysql.sock
cp mysql.server /etc/init.d/mysqld
cd ..
groupadd -g 27 mysql
useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql
chown -R mysql.mysql .
配置文件路径
cd
vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
source .bash_profile
cd /usr/local/lnmp/mysql
mysql初始化:
[root@server7 mysql]# mysqld --initialize --user=mysql
2018-08-05T03:03:52.626355Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-05T03:03:52.626440Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-08-05T03:03:52.626446Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2018-08-05T03:03:55.185519Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-05T03:03:55.731565Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-05T03:03:55.934301Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 30e22f09-985c-11e8-b408-5254004f9b52.
2018-08-05T03:03:55.973487Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-05T03:03:55.974756Z 1 [Note] A temporary password is generated for root@localhost: cXaa:>:5FqrF 密码
ll # 会出现data目录
chown -R root.root .
chown mysql data -R
/etc/init.d/mysqld start
mysql_secure_installation
[root@server7 mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
mysql安全配置
[root@server7 mysql]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
mysql -p # 进入mysql中