MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL。基于事务的Maria存储引擎,替换了MySQL的MyISAM存储引擎。虽然MariaDB被视为MySQL数据库的替代品,但它在扩展功能、存储引擎以及一些新的功能改进方面都强过MySQL。而且从MySQL迁移到MariaDB也是非常简单的。
详情点击mariadb官方站点
下载二进制包:安装包:mariadb-10.2.8
# wget https://downloads.mariadb.org/interstitial/mariadb-10.2.8/bintar-linux-x86_64/mariadb-10.2.8-linux-x86_64.tar.gz/from/http%3A//mirrors.tuna.tsinghua.edu.cn/mariadb/
解压到/usr/local下
# tar -xvf index.html -C /usr/local/
解压后的相关目录说明:
bin: 各种二进制都在此目录下data: 如果我们不创建新目录的话,此目录就是默认的数据目录。所以权限必须是属主和属组都是mysqldocs: 相关 文档include: 头文件lib: 库文件man: 帮助手册mysql-test: mysql测试组件scripts: mysql初始化时要用到的脚本share: mysql的共享内容sql-bench: 对mysql做压力测试工具support-files: mysql正常运行的样例性的配置文件或文档
做一个软连接。切换到mariadb目录下。并参考一个安装说明文档
# ln -s /usr/local/mariadb-10.2.8-linux-x86_64/ /usr/local/mysql# cd /usr/local/mysql/# vim INSTALL-BINARYshell> groupadd mysqlshell> useradd -g mysql mysqlshell> cd /usr/localshell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -shell> ln -s full-path-to-mysql-VERSION-OS mysqlshell> cd mysqlshell> chown -R mysql .shell> chgrp -R mysql .shell> scripts/mysql_install_db --user=mysqlshell> chown -R root .shell> chown -R mysql datashell> bin/mysqld_safe --user=mysql &
创建mysql用户和组,并修改mariadb下的权限
# groupadd mysql# useradd -r -s /sbin/nologin -g mysql mysql# chown -R mysql.mysql .
初始化脚本。使用mysql_install_db
初始化数据库,使用--user定义数据库名称,--basedir定义软件主目录,--datadir定义数据库的存放目录,初始化完成后,将mysql的配置文件拷贝一份到my.cnf下。然后通过软件包提供的启动脚本mysql.server来管理服务进程并启动。
# mkdir -p /data/# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/# cp support-files/my-small.cnf /etc/my.cnf# cp -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld# /etc/init.d/mysqld start Starting mysqld (via systemctl): Warning: mysqld.service changed on disk. Run 'systemctl daemon-reload' to reload units.Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [失败]
这时发现启动失败:查看日志,发现并没有什么有用的信息。
# systemctl status mysqld.service# tail -f /var/log/messagesAug 20 11:58:56 php systemd: Starting LSB: start and stop MySQL...Aug 20 11:58:57 php mysqld: Starting MySQL.170820 11:58:57 mysqld_safe Logging to '/usr/local/mysql/data/php.err'.Aug 20 11:58:57 php mysqld: 170820 11:58:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/dataAug 20 11:58:57 php mysqld: ERROR!Aug 20 11:58:57 php systemd: mysqld.service: control process exited, code=exited status=1Aug 20 11:58:57 php systemd: Failed to start LSB: start and stop MySQL.Aug 20 11:58:57 php systemd: Unit mysqld.service entered failed state.Aug 20 11:58:57 php systemd: mysqld.service failed.
在查看/data/php.err日志:发现报错信息
# tail /usr/local/mysql/data/php.err 2017-08-20 12:03:26 139715621869376 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist2017-08-20 12:03:26 139715621869376 [Note] Server socket created on IP: '::'.2017-08-20 12:03:26 139715621869376 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
经过请教得:在配置文件my.cnf的[mysqld]下添加datadir = /data/mysql
指明数据库的路径。 就好了。重启成功。
# /etc/init.d/mysqld startStarting mysqld (via systemctl): [ 确定 ]# ss -tnl|grep 3306LISTEN 0 80 :::3306 :::*
如果此时mysql依然没有启动。报错如下,你可以删除/data/mysql/下的内容再重新初始化就好了
# /etc/init.d/mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/php.pid).# cd /data/mysql/ && rm -rf *# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql/Installing MySQL system tables...OKFilling help tables...OK.......# /etc/init.d/mysqld startStarting MySQL... SUCCESS!
配置好shell环境:
# PATH=$PATH:/usr/local/mysql/bin/# echo "export PATH=$PATH:/usr/local/mysql/bin/">>/etc/profile
总结:被启动这个问题困扰了大概好几个小时。期间查询网上信息,未果。最后请教老师,被这一条语句所折服。这就足以看出经验的重要性了。
本文出自 “dianel简单不简单” 博客,请务必保留此出处http://dianel.blog.51cto.com/12170393/1957801
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。