当前位置: 首页 > news >正文

mariadb5.5.56在centos7.6环境安装

mariadb5.5.56在centos7.6环境安装

1 下载安装包

https://mariadb.org/mariadb/all-releases/#5-5

2 上传安装包的服务器

mariadb-5.5.56-linux-systemd-x86_64.tar.gz

3 解压安装包

tar -zxvf mariadb-5.5.56-linux-systemd-x86_64.tar.gz
mv mariadb-5.5.56-linux-systemd-x86_64 /mariadb

4 创建data目录

mkdir -p /data/mariadb_5_5_56

5 修改my.cnf

cp /mariadb/support_files/my-small.cnf /etc/my.cnf# cat /etc/my.cnf|grep -Ev "^$|^#"
[client]
port            = 3306
socket          = /tmp/mysql.sock
[mysqld]
basedir         = /mariadb
datadir         = /data/mariadb_5_5_56
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
server-id       = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout

6 初始化数据库

# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb_5_5_56
Installing MariaDB/MySQL system tables in '/data/mariadb_5_5_56' ...
250607 10:46:22 [Note] /mariadb/bin/mysqld (mysqld 5.5.56-MariaDB) starting as process 16500 ...
OK
Filling help tables...
250607 10:46:23 [Note] /mariadb/bin/mysqld (mysqld 5.5.56-MariaDB) starting as process 16509 ...
OKTo start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:'/mariadb/bin/mysqladmin' -u root password 'new-password'
'/mariadb/bin/mysqladmin' -u root -h exam01 password 'new-password'Alternatively you can run:
'/mariadb/bin/mysql_secure_installation'which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.You can start the MariaDB daemon with:
cd '/mariadb' ; /mariadb/bin/mysqld_safe --datadir='/data/mariadb_5_5_56'You can test the MariaDB daemon with mysql-test-run.pl
cd '/mariadb/mysql-test' ; perl mysql-test-run.plPlease report any problems at http://mariadb.org/jiraThe latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/---------------------------------------------------------------
[root@exam01 soft]# cd /data/mariadb_5_5_56/
[root@exam01 mariadb_5_5_56]# ll
total 28
-rw-rw---- 1 mysql mysql 16384 Jun  7 10:46 aria_log.00000001
-rw-rw---- 1 mysql mysql    52 Jun  7 10:46 aria_log_control
drwx------ 2 mysql root   4096 Jun  7 10:46 mysql
drwx------ 2 mysql mysql  4096 Jun  7 10:46 performance_schema
drwx------ 2 mysql root      6 Jun  7 10:46 test

7 配置启动服务

cd support_files
cp mysql.server /etc/init.d/mariadb
vi /etc/init.d/mariadb
修改basedir ,datadir路径

8 加载并启动服务

[root@exam01 support-files]# systemctl  daemon-reload
[root@exam01 mariadb]# systemctl start mariadb
[root@exam01 mariadb]# systemctl status mariadb
● mariadb.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mariadb; bad; vendor preset: disabled)Active: active (running) since Sat 2025-06-07 11:02:35 CST; 1s agoDocs: man:systemd-sysv-generator(8)Process: 17652 ExecStart=/etc/rc.d/init.d/mariadb start (code=exited, status=0/SUCCESS)Tasks: 20Memory: 79.3MCGroup: /system.slice/mariadb.service├─17666 /bin/sh /mariadb/bin/mysqld_safe --datadir=/data/mariadb_5_5_56 --pid-file=/data/mariadb_5_5_56/exam01.pid└─17936 /mariadb/bin/mysqld --basedir=/mariadb --datadir=/data/mariadb_5_5_56 --plugin-dir=/mariadb/lib/plugin --user=mysql --log...Jun 07 11:02:32 exam01 systemd[1]: Starting LSB: start and stop MySQL...
Jun 07 11:02:33 exam01 mariadb[17652]: Starting MySQL.250607 11:02:33 mysqld_safe Logging to '/data/mariadb_5_5_56/exam01.err'.
Jun 07 11:02:33 exam01 mariadb[17652]: 250607 11:02:33 mysqld_safe Starting mysqld daemon with databases from /data/mariadb_5_5_56
Jun 07 11:02:35 exam01 mariadb[17652]: . SUCCESS!
Jun 07 11:02:35 exam01 systemd[1]: Started LSB: start and stop MySQL.
[root@exam01 mariadb]# ps -ef |grep mariadb
root     17666     1  0 11:02 ?        00:00:00 /bin/sh /mariadb/bin/mysqld_safe --datadir=/data/mariadb_5_5_56 --pid-file=/data/mariadb_5_5_56/exam01.pid
mysql    17936 17666  0 11:02 ?        00:00:00 /mariadb/bin/mysqld --basedir=/mariadb --datadir=/data/mariadb_5_5_56 --plugin-dir=/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb_5_5_56/exam01.err --pid-file=/data/mariadb_5_5_56/exam01.pid --socket=/tmp/mysql.sock --port=3306

9 修改root密码

[root@exam01 mariadb]# '/mariadb/bin/mysqladmin' -u root -h exam01 password 'root'

10 验证登录失败

修改完密码之后测试登录失败,不知道问题在哪

[root@exam01 mariadb]# mysql -uroot -hlocalhost -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@exam01 mariadb]# 
[root@exam01 mariadb]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@exam01 mariadb]# 
[root@exam01 mariadb]# mysql -uroot -p -h127.0.0.1
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

11 修改密码

窗口1
[root@exam01 ~]# cd /mariadb/bin/
[root@exam01 bin]# ./mysqld_safe --skip-grant-tables &
[1] 19686
[root@exam01 bin]# 250607 11:23:50 mysqld_safe Logging to '/data/mariadb_5_5_56/exam01.err'.
250607 11:23:50 mysqld_safe Starting mysqld daemon with databases from /data/mariadb_5_5_56窗口2
[root@exam01 ~]# mysql -uroot -p
Enter password:      <<<<<<<<<<<<<  直接回车
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.56-MariaDB MariaDB ServerCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysql;
Database changed
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)mysql> update mysql.user set password=password('root') where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye

12 再次登录正常

[root@exam01 bin]# ps -ef |grep mysql
root     19686 19158  0 11:23 pts/0    00:00:00 /bin/sh ./mysqld_safe --skip-grant-tables
mysql    19944 19686  0 11:23 pts/0    00:00:00 /mariadb/bin/mysqld --basedir=/mariadb --datadir=/data/mariadb_5_5_56 --plugin-dir=/mariadb/lib/plugin --user=mysql --skip-grant-tables --log-error=/data/mariadb_5_5_56/exam01.err --pid-file=exam01.pid --socket=/tmp/mysql.sock --port=3306
root     20256 19158  0 11:28 pts/0    00:00:00 grep --color=auto mysql
[root@exam01 bin]# 
[root@exam01 bin]# 
[root@exam01 bin]# kill -9 19686 19944
[1]+  Killed                  ./mysqld_safe --skip-grant-tables
[root@exam01 bin]# 
[root@exam01 bin]# systemctl start mariadb
[root@exam01 bin]# systemctl status mariadb
● mariadb.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mariadb; bad; vendor preset: disabled)Active: active (running) since Sat 2025-06-07 11:28:25 CST; 5s agoDocs: man:systemd-sysv-generator(8)Process: 20281 ExecStart=/etc/rc.d/init.d/mariadb start (code=exited, status=0/SUCCESS)Tasks: 20Memory: 49.3MCGroup: /system.slice/mariadb.service├─20295 /bin/sh /mariadb/bin/mysqld_safe --datadir=/data/mariadb_5_5_56 --pid-file=/data/mariadb_5_5_56/exam01.pid└─20567 /mariadb/bin/mysqld --basedir=/mariadb --datadir=/data/mariadb_5_5_56 --plugin-dir=/mariadb/lib/plugin --user=mysql --log...Jun 07 11:28:23 exam01 systemd[1]: Starting LSB: start and stop MySQL...
Jun 07 11:28:24 exam01 mariadb[20281]: Starting MySQL.250607 11:28:24 mysqld_safe Logging to '/data/mariadb_5_5_56/exam01.err'.
Jun 07 11:28:24 exam01 mariadb[20281]: 250607 11:28:24 mysqld_safe Starting mysqld daemon with databases from /data/mariadb_5_5_56
Jun 07 11:28:25 exam01 mariadb[20281]: . SUCCESS!
Jun 07 11:28:25 exam01 systemd[1]: Started LSB: start and stop MySQL.
[root@exam01 bin]# pwd
/mariadb/bin
[root@exam01 bin]# ./mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB ServerCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> 

在这里插入图片描述
附:
第10步骤 登录失败的原因已经找到,由于第9步修改密码的时候指定了host的主机名。在mysql.user表记录的是root ,exam01

MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> 
MariaDB [mysql]> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
|      | exam01    |
| root | exam01    |   <<<<<<<<<<<<<<<<<<
|      | localhost |
| root | localhost |
+------+-----------+
6 rows in set (0.00 sec)

尝试指定host主机名是可以正常登录的。

[root@exam01 bin]# mysql -uroot -hexam01 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.56-MariaDB MariaDB ServerCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 

相关文章:

  • JVM 垃圾回收器 详解
  • Python网页自动化测试,DrissonPage库入门说明文档
  • Spring Boot 3.3 + MyBatis 基础教程:从入门到实践
  • Android座舱系统Agent改造方案
  • cmake编译LASzip和LAStools
  • CVE-2023-25194源码分析与漏洞复现(Kafka JNDI注入)
  • Java优化:双重for循环
  • 2023年ASOC SCI2区TOP,随机跟随蚁群优化算法RFACO,深度解析+性能实测
  • B站Miachael_ee——蓝牙教程笔记
  • 又是一年高考季
  • Redis 与 MySQL 数据一致性保障方案
  • 微服务架构实战:Nacos 单机版的安装与启动流程
  • 2.4 vcpkg 使用
  • Linux 文件系统与 I/O 编程核心原理及实践笔记
  • 关于队列的使用
  • 6.7本日总结
  • python打卡day47
  • 第1讲、包管理和环境管理工具Conda 全面介绍
  • 理想汽车5月交付40856辆,同比增长16.7%
  • 《开篇:课程目录》
  • wordpress页面位置/成都做整站优化
  • 中石化第四建设有限公司网站/天津网站优化公司
  • 做网站美工 电脑配件要多大/网络宣传渠道
  • 每天做任务得钱的网站/找seo外包公司需要注意什么
  • 写作网站5妙不写就删除/商旅平台app下载
  • 中山高端网站建设公司/电脑培训机构