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

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> 
http://www.xdnf.cn/news/12580.html

相关文章:

  • python怎么读shape文件?
  • GPU集群故障分析:大型AI训练中的硬件问题与影响
  • 408第一季 - 数据结构 - 字符串和KMP算法
  • 快速了解:单北斗终端的定义、作用与好处!
  • Qt(part 2)1、Qwindow(菜单栏,工具栏,状态栏),铆接部件,核心部件 ,2、添加资源文件 3、对话框
  • 随访系统安装的记录
  • 【Hot 100】84. 柱状图中最大的矩形
  • 数据库管理与高可用-MySQL高可用
  • 编程基础:执行流
  • Profinet转CanOpen网关模块:铝业车间通信“破壁者”,引领工业新变革
  • MS2691 全频段、多模导航、射频低噪声放大器芯片,应用于导航仪 双频测量仪
  • win32相关(IAT HOOK)
  • 【RTSP从零实践】1、根据RTSP协议实现一个RTSP服务
  • STM32什么是寄存器
  • 24、std::hash
  • conda环境配置(一) —— 常用虚拟环境操作命令
  • 新时代AI发展,更好的做自己
  • 第1讲、包管理和环境管理工具Conda 全面介绍
  • VB.net复制Ntag213卡写入UID
  • [C++] list双向链表使用方法
  • 深入理解 Java 多线程:原理剖析与实战指南
  • 乐观锁与悲观锁的实现和应用
  • 统一点云数据格式:高效转换与属性保留
  • 微服务架构的性能优化:链路追踪与可观测性建设
  • 基于Python学习《Head First设计模式》第六章 命令模式
  • PHP 表单 - 验证邮件和URL
  • Java+Access综合测评系统源码分享:含论文、开题报告、任务书全套资料
  • 物联网智慧医院建设方案(PPT)
  • JMeter-SSE响应数据自动化2.0
  • # STM32F103 SD卡读写程序