MariaDB 的安装与配置

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 这个是本人最早接触的一篇数据库配置,也是让我入门Linux基础环境搭建的一篇,有时候忘了命令也会参考里面的内容# rpm -ivh 12-cmake-2.8.11.1-5.


这个是本人最早接触的一篇数据库配置,也是让我入门Linux基础环境搭建的一篇,有时候忘了命令也会参考里面的内容


# rpm -ivh 12-cmake-2.8.11.1-5.1.x86_64.rpm 

warning: cmake-2.8.11.1-5.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6aaf6b3f: NOKEY

Preparing...                (10########################################### [100%]

   1:cmake                   (  ########################################### [100%]

#tar -zxvf 13-mariadb-5.5.48-linux-glibc_214-x86_64.tar.gz

# mv mariadb-5.5.48-linux-x86_64 /usr/local/

# groupadd mysql

# useradd -g mysql mysql

# id mysql

uid=500(mysql) gid=500(mysql) groups=500(mysql)

# ln -s mariadb-5.5.48-linux-x86_64/ mysql

# cd mysql/

#cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

# ./scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...

160227  0:23:45 [Note] ./bin/mysqld (mysqld 5.5.48-MariaDB) starting as process 1105 ...OK

Filling help tables...

160227  0:23:47 [Note] ./bin/mysqld (mysqld 5.5.48-MariaDB) starting as process 1112 ...OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

#cp support-files/mysql.server /etc/init.d/

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !

To do so, start the server, then issue the following commands:


启动数据库:

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/usr/local/mysql/data --user=mysql &

'./bin/mysqladmin' -u root password 'new-password'

'./bin/mysqladmin' -u root -h php.myfamily password 'new-password'

Alternatively you can run:

'./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 '.' ; ./bin/mysqld_safe --datadir='/var/lib/mysql'

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/.

You can find additional information about the MySQL part at:

http://dev.mysql.com

Support MariaDB development by buying support/new features from MariaDB

Corporation Ab. You can contact us about this at sales@mariadb.com.

Alternatively consider joining our community based development effort:

http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

# chown -R root .

# chown -R mysql data

# vi .bash_profile 

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin/:/usr/local/apache2/bin/:/usr/local/php/bin/

:wq


启动数据库:

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/usr/local/mysql/data --user=mysql &


设置开机自动启动数据库:

#vi /etc/rc.local

add

/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/usr/local/mysql/data --user=mysql &

:wq


#reboot


修改mysql root密码:

#'./bin/mysqladmin' -u root password 'new-password'

or

# ./mysql_secure_installation 

# ./bin/mysql -u root -p

Enter password: 

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 5.5.48-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]> use mysql;

Database changed

MariaDB [mysql]> show tables;

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

24 rows in set (0.00 sec)

MariaDB [mysql]> select host, user from user;

+--------------+------+

| host         | user |

+--------------+------+

| 127.0.0.1    | root |

| ::1          | root |

| localhost    |      |

| localhost    | root |

| php.myfamily |      |

| php.myfamily | root |

+--------------+------+

6 rows in set (0.00 sec)

MariaDB [mysql]> update user set host='%' where user='root' and host='localhost';

Query OK, 1 row affected (0.05 sec)

Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> select host, user from user;

+--------------+------+

| host         | user |

+--------------+------+

| %            | root |

| 127.0.0.1    | root |

| ::1          | root |

| localhost    |      |

| php.myfamily |      |

| php.myfamily | root |

+--------------+------+

6 rows in set (0.00 sec)

MariaDB [mysql]> delete from user where user='';

Query OK, 2 rows affected (0.03 sec)


修改数据库密码:

mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; 

MariaDB [mysql]> select host, user, password from user;

+--------------+------+-------------------------------------------+

| host         | user | password                                  |

+--------------+------+-------------------------------------------+

| %            | root | *0D2B78B43FD0518B55EFD87FC2C1FB6775F8AB07 |

| php.myfamily | root | *0D2B78B43FD0518B55EFD87FC2C1FB6775F8AB07 |

| 127.0.0.1    | root | *0D2B78B43FD0518B55EFD87FC2C1FB6775F8AB07 |

| ::1          | root | *0D2B78B43FD0518B55EFD87FC2C1FB6775F8AB07 |

+--------------+------+-------------------------------------------+

4 rows in set (0.00 sec)

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit

Bye

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)


修改防火墙配置;

# vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

:wq


如果遇到下面的错误:

ERROR 1045 (28000): Access denied for user 'root'@'localhost'

ps -ef | grep mysqld

查询确认mysql的pid,然后kill -9 xx

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 

# mysql -u root mysql 

mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; 

mysql> FLUSH PRIVILEGES; 

mysql> quit 

# /etc/init.d/mysql restart 

# mysql -uroot -p 

Enter password: <输入新设的密码newpassword> 

mysql> 



相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
目录
相关文章
|
1月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
145 18
|
1月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
151 15
|
6月前
|
Java 关系型数据库 MySQL
JDK、Tomcat、MariaDB数据库和Profile多环境的配置与使用
以上就是JDK、Tomcat、MariaDB数据库和Profile多环境的配置与使用的基本步骤。这些步骤可能会因为你的具体需求和环境而有所不同,但是基本的思路是一样的。希望这些信息能够帮助你更好地理解和使用这些工具。
225 17
|
Java 关系型数据库 MySQL
"解锁Java Web传奇之旅:从JDK1.8到Tomcat,再到MariaDB,一场跨越数据库的冒险安装盛宴,挑战你的技术极限!"
【8月更文挑战第19天】在Linux上搭建Java Web应用环境,需安装JDK 1.8、Tomcat及MariaDB。本指南详述了使用apt-get安装OpenJDK 1.8的方法,并验证其版本。接着下载与解压Tomcat至`/usr/local/`目录,并启动服务。最后,通过apt-get安装MariaDB,设置基本安全配置。完成这些步骤后,即可验证各组件的状态,为部署Java Web应用打下基础。
213 1
|
SQL 分布式计算 Hadoop
Hadoop-12-Hive 基本介绍 下载安装配置 MariaDB安装 3台云服务Hadoop集群 架构图 对比SQL HQL
Hadoop-12-Hive 基本介绍 下载安装配置 MariaDB安装 3台云服务Hadoop集群 架构图 对比SQL HQL
274 3
|
11月前
|
关系型数据库 MySQL Linux
Linux-安装Mariadb
本文介绍了在 Alibaba Cloud Linux 系统上安装和配置 MariaDB 10.5 的步骤。包括下载安装、初始化数据库、启动服务、处理启动失败的常见问题(如权限问题),以及如何连接数据库、设置密码和允许外部连接。通过这些步骤,您可以顺利完成 MariaDB 的安装和基本配置。
1066 0
|
关系型数据库 Java MySQL
Linux安装JDK1.8 & tomcat & MariaDB(MySQL删减版)
本教程提供了在Linux环境下安装JDK1.8、Tomcat和MariaDB的详细步骤。这三个组件的组合为Java Web开发和部署提供了一个强大的基础。通过遵循这些简单的指导步骤,您可以轻松建立起一个稳定、高效的开发和部署环境。希望这个指导对您的开发工作有所帮助。
427 8
|
Oracle 关系型数据库 MySQL
CentOS7安装MariaDB成功的实践
CentOS7安装MariaDB成功的实践
328 0
|
关系型数据库 Java MySQL
"解锁Java Web传奇之旅:从JDK1.8到Tomcat,再到MariaDB,一场跨越数据库的冒险安装盛宴,挑战你的技术极限!"
【9月更文挑战第6天】在Linux环境下安装JDK 1.8、Tomcat和MariaDB是搭建Java Web应用的关键步骤。本文详细介绍了使用apt-get安装OpenJDK 1.8、下载并配置Tomcat,以及安装和安全设置MariaDB(MySQL的开源分支)的方法。通过这些步骤,您可以快速构建一个稳定、高效的开发和部署环境,并验证各组件是否正确安装和运行。这为您的Java Web应用提供了一个坚实的基础。
199 0
|
SQL 分布式计算 关系型数据库
Hadoop-12-Hive 基本介绍 下载安装配置 MariaDB安装 3台云服务Hadoop集群 架构图 对比SQL HQL
Hadoop-12-Hive 基本介绍 下载安装配置 MariaDB安装 3台云服务Hadoop集群 架构图 对比SQL HQL
190 2

热门文章

最新文章

推荐镜像

更多