Mysql一次安裝問題記錄
阿新 • • 發佈:2022-11-29
本次在redhat8.7的系統上安裝MySQL5.7.37版本,關於一些啟動失敗的問題
MySQL包地址:
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.37-el7-x86_64.tar.gz
安裝指令碼
#!/bin/bash set -ex ###Mysql5.7二進位制包 指令碼安裝 ##準備環境:一個足夠大的硬碟空間 ## 變數檔案 #initdir=/app ##基礎目錄 basedir=/usr/local/mysql ## mysql安裝二進位制包目錄 datadir=/data/mysql ## mysql資料目錄 logdir=/var/log/mysql ## mysql日誌檔案 bin_log=$datadir/binlog/mysql-bin relay_log=$datadir/relay-log/mysql-relay server_id=2 mysql_name=mysql-5.7.37-el7-x86_64 ## 建立初始目錄、使用者 #mkdir -p $initdir useradd -s /sbin/nologin mysql ## 清理mariadb環境 if &>/dev/null ;then yum remove mariadb-libs -y fi # 安裝mysql #wget $mysql_url echo"正在解壓mysql" tar -zxf $mysql_name.tar.gz echo "解壓完畢" sleep 2 mv $mysql_name $basedir chown -R mysql:mysql $basedir if [ ! -d $datadir ];then mkdir -p $datadir fi chown -R mysql:mysql $datadir mkdir $logdir chown -R mysql:mysql $logdir echo "export basedir=$basedir" >> /etc/profile echo 'export PATH=$basedir/bin:$PATH' >> /etc/profile source /etc/profile ## mysql初始化 mysqld --initialize-insecure --user=mysql --basedir=$basedir --datadir=$datadir mkdir -p $bin_log mkdir -p $relay_log chown -R mysql:mysql $datadir ## mysql配置檔案 cat > /etc/my.cnf << EOF [mysqld] basedir = $basedir datadir = $datadir pid-file = /tmp/mysql.pid socket = /tmp/mysql.sock port = 3306 user = root log_error = $logdir/mysql-error.log slow-query-log-file = $logdir/mysql-slow.log log_bin = $bin_log relay-log = $relay_log server-id = ${server_id} innodb_buffer_pool_size = 1024M innodb_log_buffer_size = 16M key_buffer_size = 128M query_cache_size = 256M tmp_table_size = 128M binlog_format = mixed skip-external-locking skip-name-resolve character-set-server = utf8 collation-server = utf8_bin max_allowed_packet = 16M thread_cache_size = 256 table_open_cache = 4096 back_log = 1024 max_connect_errors = 100000 interactive_timeout = 1800 wait_timeout = 1800 max_connections = 500 sort_buffer_size = 16M join_buffer_size = 4M read_buffer_size = 4M read_rnd_buffer_size = 16M binlog_cache_size = 2M thread_stack = 192K max_heap_table_size = 128M myisam_sort_buffer_size = 128M bulk_insert_buffer_size = 256M open_files_limit = 65535 query_cache_limit = 2M slow-query-log long_query_time = 2 expire_logs_days = 3 max_binlog_size = 1000M slave_parallel_workers = 4 log-slave-updates binlog_ignore_db = mysql replicate_wild_ignore_table = mysql.% sync_binlog = 1 innodb_file_per_table = 1 innodb_flush_method = O_DIRECT innodb_buffer_pool_instances = 4 innodb_log_file_size = 512M innodb_log_files_in_group = 3 innodb_open_files = 4000 innodb_read_io_threads = 8 innodb_write_io_threads = 8 innodb_thread_concurrency = 8 innodb_io_capacity = 2000 innodb_io_capacity_max = 6000 innodb_lru_scan_depth = 2000 innodb_max_dirty_pages_pct = 85 innodb_flush_log_at_trx_commit = 2 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqldump] quick quote-names max_allowed_packet = 16M [client] default-character-set = utf8 [mysql] default-character-set = utf8 [isamchk] key_buffer = 128M sort_buffer_size = 4M read_buffer = 2M write_buffer = 2M [myisamchk] key_buffer = 128M sort_buffer_size = 4M read_buffer = 2M write_buffer = 2M EOF ## 建立systemd管理檔案 cat > /etc/systemd/system/mysqld.service << EOF [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=$basedir/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 EOF systemctl daemon-reload systemctl start mysqld systemctl enable mysqld systemctl status mysqld
安裝都照常進行,到最後,無法啟動(這個其實由於粗心引起的)
報錯為:
這個許可權問題其實是selinux導致的,關閉selinux即可
setenforce 0 vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
主要是一下問題,登陸的時候出現該報錯
查詢半天后,解決方法如下:
yum install libncurs* -y rm -f /usr/lib64/libtinfo.so.5 ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5 rm -f rm -f /lib64/libncurses.so.5 ln -s /lib64/libncurses.so.6.1 /lib64/libncurses.so.5
主要應該是一些類包版本的問題,具體原因還未深究,待有時間深究一下