mysql源码编译安装
生活随笔
收集整理的這篇文章主要介紹了
mysql源码编译安装
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
MySQL是一種關(guān)系型數(shù)據(jù)庫管理系統(tǒng),關(guān)系數(shù)據(jù)庫將數(shù)據(jù)保存在不同的表中,而不是將所有數(shù)據(jù)放在一個大倉庫內(nèi),這樣就增加了速度并提高了靈活性。由瑞典MySQL AB 公司開發(fā),屬于 Oracle 旗下產(chǎn)品。
tar zxf mysql-boost-5.7.31.tar.gz ##解壓安裝包 cd mysql-5.7.31/ less INSTALL yum install cmake -y ##安裝cmake然后進行安裝三步驟,注意:安裝mysql不是使用configure,而是使用cmake
cmake——make——make install
根據(jù)提示下載安裝一些所需要的模塊和庫
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_unicode_ci -DWITH_BOOST=boost/boost_1_59_0/yum install -y gcc-c++ yum install ncurses-devel -y rm -f CMakeCache.txt yum install -y bison cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_unicode_ci -DWITH_BOOST=boost/boost_1_59_0/makemake installcmake不同于configure的是,每次cmake結(jié)果會被緩存,所以在安裝新的庫之前我們可以先刪除CMakeCache.txt清理緩存,然后重新進行cmake
?安裝完成后可以看到生成目錄mysql
創(chuàng)建用戶及目錄,更改目錄所有人及所有組
[root@server1 mysql]# cd support-files [root@server1 support-files]# ls magic mysqld_multi.server mysql-log-rotate mysql.server [root@server1 support-files]# cp mysql.server /etc/init.d/mysqld[root@server1 support-files]# useradd -M -d /data/mysql -s /sbin/nologin mysql [root@server1 support-files]# id mysql uid=1001(mysql) gid=1001(mysql) groups=1001(mysql) [root@server1 support-files]# mkdir -p /data/mysql [root@server1 support-files]# chown mysql.mysql /data/mysql設(shè)置使用mysql命令
[root@server1 support-files]# cd /usr/local/mysql [root@server1 mysql]# cd bin/ [root@server1 bin]# pwd /usr/local/mysql/bin [root@server1 bin]# vim ~/.bash_profilePATH=$PATH:$HOME/bin:/usr/local/mysql/bin[root@server1 bin]# source ~/.bash_profile[root@server1 ~]# which mysql ##就可以使用mysql底下的命令了 /usr/local/mysql/bin/mysql?修改配置文件,更改路徑
[root@server1 mysql-5.7.31]# vim /etc/my.cnf [mysqld] basedir=/usr/local/mysql datadir=/data/mysql socket=/data/mysql/mysql.sock symbolic-links=0 log-error=/data/mysql/mysqld.log pid-file=/data/mysql/mysqld.pid初始化,查看隨機密碼
[root@server1 mysql-5.7.31]# mysqld --initialize --user=mysql [root@server1 mysql]# cat mysqld.log ##可以查看隨機密碼2021-12-10T06:01:51.140004Z 1 [Note] A temporary password is generated for root@localhost: yjA0kGZ8Fs-x[root@server1 mysql]# /etc/init.d/mysqld start Starting MySQL. SUCCESS!注意:
如果需要重新啟動mysql,關(guān)閉進程,清空/data/mysql,重新初始化之后打開
安全初始化設(shè)置密碼
[root@server1 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: ##設(shè)置新密碼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!設(shè)置完成,登陸mysql
?
總結(jié)
以上是生活随笔為你收集整理的mysql源码编译安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 批量 材质 调整_超实用的3dmax技巧
- 下一篇: Python实现基于模块的库存管理系统