Ubuntu 18.04 LTS宝塔面板无法安装mysql解决方法

起因

我打算在本地搭建Nginx+Mysql+Php环境,开了个虚拟机,系统是Ubuntu 18.04 LTS
我用惯了宝塔面板,于是在装好系统的时候第一件事—装宝塔面板【5.8.7】。
but,我装Mysql 5.5的时候,到80%几就停了。。
emmmmmmmmmm…..
想要一键脚本安装的同学点这里

大致探索过程

然后我从宝塔面板目录找出了安装Mysql的shell脚本—mysql.sh
于是我手动安装了试试,依然不行。。。。
把那个错误【2674行field_names[i][num_fields2]= ‘\0’;】百度大概半小时,终于知道了
要把field_names[i][num_fields
2]= ‘\0’;改成field_names[i][num_fields*2]= NULL;

手动安装过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sudo apt install cmake gcc g++ make libncurses5 libncurses5-dev -y
sudo su
cd /root
mkdir -p /www/server/mysql
rm -rf /www/server/mysql/*
cd /www/server/mysql
wget -O /www/server/mysql/src.tar.gz http://download.bt.cn/src/mysql-5.5.59.tar.gz -T20
tar -zxvf src.tar.gz
mkdir -p src
mv mysql-5.5.59/* src
cd /www/server/mysql/src/
sed -i '2674i\field_names[i][num_fields*2]= NULL;' /www/server/mysql/src/client/mysql.cc
sed -i '2675d' /www/server/mysql/src/client/mysql.cc
cmake -DCMAKE_INSTALL_PREFIX=/www/server/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1
make && make install
groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cat > /etc/my.cnf<<EOF
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock

[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /www/server/data
default_storage_engine = MyISAM
#skip-external-locking
#loose-skip-innodb
key_buffer_size = 8M
max_allowed_packet = 100G
table_open_cache = 32
sort_buffer_size = 256K
net_buffer_length = 4K
read_buffer_size = 128K
read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 4M
thread_cache_size = 4
query_cache_size = 4M
tmp_table_size = 8M

#skip-networking
#skip-name-resolve
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id = 1
expire_logs_days = 10
slow_query_log=1
slow-query-log-file=/www/server/data/mysql-slow.log
long_query_time=3
#log_queries_not_using_indexes=on

default_storage_engine = InnoDB
innodb_data_home_dir = /www/server/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /www/server/data
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
EOF
1
2
3
4
5
6
7
8
9
mkdir -p /www/server/data
rm -rf /www/server/data/*
chown -R mysql:mysql /www/server/data
/www/server/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/www/server/mysql --datadir=/www/server/data --user=mysql
chgrp -R mysql /www/server/mysql/.
\cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
sed -i "s#\"\$\*\"#--sql-mode=\"NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\"#" /etc/init.d/mysqld
sed -i '/case "$mode" in/i\ulimit -s unlimited' /etc/init.d/mysqld
1
2
3
4
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
/www/server/mysql/lib
/usr/local/lib
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
ldconfig
chown mysql:mysql /etc/my.cnf
ln -sf /www/server/mysql/lib/mysql /usr/lib/mysql
ln -sf /www/server/mysql/include/mysql /usr/include/mysql
/etc/init.d/mysqld start
SetLink
ldconfig
/www/server/mysql/bin/mysqladmin -u root password "${mysqlpwd}"
update-rc.d mysqld defaults
cd /www/server/mysql
rm -f src.tar.gz
rm -rf src
echo "5.5.59" > /www/server/mysql/version.pl

然后就能看到宝塔面板里有了!!!Mysql
“宝塔mysql”

一键脚本

一键脚本施工完成

1
cd ~ && wget https://mchank.top/downloads/install-mysql5.5.59-on-ub18.04.sh && sudo bash install-mysql5.5.59-on-ub18.04.sh

中途输入sudo密码即可
mysql root的初始密码是admin
仅支持Ubuntu 18.04 LTS,宝塔面板目录在/www下的系统安装

本文标题:Ubuntu 18.04 LTS宝塔面板无法安装mysql解决方法

文章作者:hank9999

发布时间:2018年05月07日 - 12:05

最后更新:2019年07月19日 - 20:07

原始链接:https://mchank.top/solve_bt-panel-can-not-install-mysql/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。