记录 debian 12 bullseye 下手动安装mariadb10.4.33
由于 系统比较旧 需要用到 mariadb 10.3 - 10.4 的版本,于是下载了 10.4.33 的版本。
记录一下 在debian 12 bullseys 下的安装过程:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mariadb-10.4.33-linux-systemd-x86_64 | tar xvf -
shell> ln -s mariadb-10.4.33-linux-systemd-x86_64 mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
进行到上一步报错,如下:
root@debian:/usr/local/mysql# scripts/mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in './data' ...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directoryInstallation of system tables failed! Examine the logs in
./data for more information.The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:shell> scripts/mysql_install_db --defaults-file=~/.my.cnf
You can also try to start the mysqld daemon with:
shell> ./bin/mysqld --skip-grant-tables --general-log &
and use the command line tool ./bin/mysql
to connect to the mysql database and look at the grant tables:shell> ./bin/mysql -u root mysql
mysql> show tables;Try 'mysqld --help' if you have problems with paths. Using
--general-log gives you a log in ./data that may be helpful.The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discussPlease check all of the above before submitting a bug report
at http://mariadb.org/jira
尝试解决:apt-get install libaio1 ,之后再执行上一步 数据初始化正常了
提示如下:
root@debian:/usr/local/mysql# scripts/mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in './data' ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo
See the MariaDB Knowledgebase at http://mariadb.com/kb
You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='./data'
You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
./mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
解决方法:apt-get install libncurses5
创建 /etc/my.cnf
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 [mysqld] 2 port=3306 3 datadir=/usr/local/mysql/data #数据路径 4 socket=/tmp/mysql.sock #sock路径 5 skip-grant-tables 6 [mysqld_safe] 7 log-error=/var/log/mariadb.log #日志存放路径 8 pid-file=/var/log/mariadb.pid #pid路径
将 support-file/systemd/mariadb.service 拷贝到 /etc/systemd/system 内
进行编辑 看看对应目录是否正常
准备启动:
systemctl start mariadb
查看 systemctl status mariadb
结果:
● mariadb.service - MariaDB 10.4.33 database server
Loaded: loaded (/etc/systemd/system/mariadb.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-08-10 13:22:05 CST; 10min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 2210 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 2212 ExecStartPre=/bin/sh -c [ ! -e /usr/local/mysql/bin/galera_recovery ] && VAR= || VAR=`cd /usr/local/mysql/bin/..; /usr/local/mysql/bin/gale>
Process: 2263 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 2232 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 14804)
Memory: 78.6M
CPU: 405ms
CGroup: /system.slice/mariadb.service
└─2232 /usr/local/mysql/bin/mysqld
表示 mariadb 启动正常