Linux MYSQL5 6免編譯二進位製包安裝

2021-09-08 06:52:26 字數 3987 閱讀 1964

系統版本為centos7,建議使用root使用者登入系統操作

[root@localhost ~]# rpm -e --nodeps mariadb-libs
[root@localhost ~]# yum install -y ncurses-devel libaio-devel
[root@localhost ~]# groupadd -r mysql

[root@localhost ~]# useradd -g mysql -r mysql

[root@localhost ~]# mkdir -pv /opt/tmp

[root@localhost ~]# mkdir -pv /opt/mysql/data

[root@localhost ~]# chown -r mysql:mysql /opt/mysql

[root@localhost ~]# cd /opt/tmp/

[root@localhost tmp]# wget

[root@localhost tmp]tar xf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz -c /usr/local/

[root@localhost tmp]# cd /usr/local/

[root@localhost local]# ln -sv mysql-5.6.41-linux-glibc2.12-x86_64 mysql

[root@localhost local]# chown -r mysql:root mysql-5.6.41-linux-glibc2.12-x86_64

[root@localhost local]# vi /etc/my.cnf
寫入如下配置項:

[client]

port = 3306

socket = /opt/mysql/data/mysql.sock

default_character_set=utf8

[mysqld]

server_id = 1

user = mysql

port = 3306

socket = /opt/mysql/data/mysql.sock

character-set-server = utf8

basedir = /usr/local/mysql

datadir = /opt/mysql/data

lower_case_table_names = 1

default_storage_engine = innodb

innodb_file_per_table = 1

innodb_buffer_pool_size = 1g #(大小為物理記憶體的80%)

skip_external_locking

federated

sort_buffer_size = 2m

key_buffer_size=800m

read_buffer_size = 256k

read_rnd_buffer_size=2m

table_open_cache = 1000

max_connections = 1000

max_allowed_packet = 50m

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

wait_timeout = 600

interactive_timeout = 600

log_bin = mysql-bin

log-error = /opt/mysql/data/mysql-error.log

max_binlog_size = 1g

long_query_time = 2

slow-query-log = 1

slow_query_log_file = /opt/mysql/data/mysql-slow.log

expire_logs_days = 3

log_bin_trust_function_creators = 1

[mysqldump]

quick

max_allowed_packet = 500m

[mysql]

no-auto-rehash

default-character-set = utf8

[root@localhost local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@localhost local]# vi /etc/init.d/mysqld

修改如下配置項:

basedir=/usr/local/mysql

datadir=/opt/mysql/data

[root@localhost local]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/opt/mysql/data
[root@localhost local]# service mysqld start

[root@localhost local]# chkconfig --add mysqld

[root@localhost local]# chkconfig mysqld on

[root@localhost local]# vim /etc/profile.d/mysql.sh
新增如下內容:

export path=/usr/local/mysql/bin:$path
[root@localhost local]# chmod +x /etc/profile.d/mysql.sh

[root@localhost local]# source /etc/profile.d/mysql.sh

[root@localhost local]# source /etc/profile.d/mysql.sh
[root@localhost local]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf

[root@localhost local]# ldconfig

[root@localhost local]# mysql
以下操作均在mysql命令列,「mysql>」為命令列提示符。

1、設定root使用者密碼:

mysql> use mysql;

mysql> update user set password = password('root') where user='root';

mysql> flush privileges;

注意:password()是mysql的密碼函式,密碼是引號中間的字元,不含引號,密碼需符合複雜度策略。

2、刪除匿名使用者:

mysql> drop user ''@localhost;
3、刪除測試庫(根據實際情況選擇是否需要操作):

mysql>drop database test;
3、退出mysql命令列

mysql> exit;
至此,資料庫安裝完成。可根據實際安裝環境配置授權使用者,出於安全考慮,應避免使用%

linux mysql 5 7 9免編譯版安裝

好像mysql5.7之後的tag包,不用編譯了,可以直接安裝.解壓mysql 5.7.9的安裝包後,開啟install binary,裡面有詳細的安裝命令,這裡稍加修改即可正確安裝 shell groupadd mysql shell useradd r g mysql mysql shell cd...

編譯mysql5 6 編譯安裝mysql5 6

mysqlwget tar zxvf mysql 5.6.33.tar.gz tar zxvf cmake 2.8.5.tar.gz cd cmake 2.8.5 安裝編譯工具.bootstrap prefix usr local cmake sudo gmake sudo gmake instal...

二進位制安裝Mysql 5 6(免編譯)

安裝系統基礎軟包yum install y make bc perl gcc openssl openssl devel ncurses ncurses devel 安裝方式 二進位制免編譯安裝 檢視linux多少位 uname i x86 64 cd usr local src wget 初始化 ...