日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql源码编译安装

發布時間:2023/12/31 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql源码编译安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MySQL是一種關系型數據庫管理系統,關系數據庫將數據保存在不同的表中,而不是將所有數據放在一個大倉庫內,這樣就增加了速度并提高了靈活性。由瑞典MySQL AB 公司開發,屬于 Oracle 旗下產品。

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

根據提示下載安裝一些所需要的模塊和庫

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 install

cmake不同于configure的是,每次cmake結果會被緩存,所以在安裝新的庫之前我們可以先刪除CMakeCache.txt清理緩存,然后重新進行cmake

?安裝完成后可以看到生成目錄mysql

創建用戶及目錄,更改目錄所有人及所有組

[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

設置使用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,關閉進程,清空/data/mysql,重新初始化之后打開

安全初始化設置密碼

[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: ##設置新密碼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

?

總結

以上是生活随笔為你收集整理的mysql源码编译安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。