linux 怎么部署mysql数据库

linux 怎么部署mysql数据库,第1张

创建用于执行mysql服务程序的帐号:

[root@linuxprobe cmake-28112]# cd

[root@linuxprobe src]# useradd mysql -s /sbin/nologin

创建数据库程序和文件的目录,并设置目录的所属与所组:

[root@linuxprobe src]# mkdir -p /usr/local/mysql/var

[root@linuxprobe src]# chown -Rf mysql:mysql /usr/local/mysql

安装Mysql服务程序(解压与编译过程已省略):

[root@linuxprobe src]# tar xzvf mysql-5619targz

[root@linuxprobe src]# cd mysql-5619/

[root@linuxprobe mysql-5619]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc

[root@linuxprobe mysql-5619]# make

[root@linuxprobe mysql-5619]# make install

删除系统默认的配置文件:

[root@linuxprobe mysql-5619]# rm -rf /etc/mycnf

生成系统数据库(生成信息已省略):

[root@linuxprobe mysql-5619]# cd /usr/local/mysql

[root@linuxprobe mysql]# /scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var

创建配置文件的软连接文件:

[root@linuxprobe mysql]# ln -s mycnf /etc/mycnf

将mysqld服务程序添加到开机启动项:

[root@linuxprobe mysql]# cp /support-files/mysqlserver /etc/rcd/initd/mysqld

[root@linuxprobe mysql]# chmod 755 /etc/initd/mysqld

[root@linuxprobe mysql]# chkconfig mysqld on

编辑启动项的配置文件:

[root@linuxprobe mysql]# vim /etc/rcd/initd/mysqld

//分别修改第46与47行,basedir为程序安装路径,datadir为数据库存放目录。

basedir=/usr/local/mysql

datadir=/usr/local/mysql/var

重启mysqld服务程序:

[root@localhost mysql]# service mysqld start

Starting MySQL SUCCESS!

把mysql服务程序命令目录添加到环境变量中(永久生效):

[root@linuxprobe mysql]# vim /etc/profile

//在配置文件的最下面追加:

export PATH=$PATH:/usr/local/mysql/bin

[root@linuxprobe mysql]# source /etc/profile

将mysqld服务程序的库文件链接到默认的位置:

[root@linuxprobe mysql]# mkdir /var/lib/mysql

[root@linuxprobe mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

[root@linuxprobe mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql

[root@linuxprobe mysql]# ln -s /tmp/mysqlsock /var/lib/mysql/mysqlsock

初始化mysqld服务程序:

[root@linuxprobe mysql]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here

Enter current password for root (enter for none):

OK, successfully used password, moving on

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation

Set root password [Y/n] y

New password: 输入要为root用户设置的数据库密码。

Re-enter new password: 重复再输入一次密码。

Password updated successfully!

Reloading privilege tables

Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them This is intended only for testing, and to make the installation

go a bit smoother You should remove them before moving into a

production environment

Remove anonymous users [Y/n] y(删除匿名帐号)

Success!

Normally, root should only be allowed to connect from 'localhost' This

ensures that someone cannot guess at the root password from the network

Disallow root login remotely [Y/n] y(禁止root用户从远程登陆)

Success!

By default, MySQL comes with a database named 'test' that anyone can

access This is also intended only for testing, and should be removed

before moving into a production environment

Remove test database and access to it [Y/n] y(删除test数据库并取消对其的访问权限)

- Dropping test database

Success!

- Removing privileges on test database

Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately

Reload privilege tables now [Y/n] y(刷新授权表,让初始化后的设定立即生效)

Success!

All done! If you've completed all of the above steps, your MySQL

installation should now be secure

Thanks for using MySQL!

Cleaning up

可以百度搜索Linux就该这么学,第9章 使用Apache服务部署静态网站,里面有部署mysql的资料

主从部署是一种常见的数据库架构方式,其中一个数据库服务器(主节点)处理写入 *** 作,而其他多个数据库服务器(从节点)复制主节点的数据并处理读取 *** 作。以下是一些常见的主从部署的数据库:

MySQL:MySQL是一种流行的开源关系型数据库,支持主从复制。在MySQL主从复制中,主服务器将所有写入 *** 作记录到二进制日志中,并通过网络将这些 *** 作转发给从服务器进行复制。

PostgreSQL:PostgreSQL是一种高度可扩展的开源关系型数据库,支持主从复制。在PostgreSQL主从复制中,主服务器将所有写入 *** 作记录到WAL(写前日志)中,并通过网络将这些 *** 作转发给从服务器进行复制。

MongoDB:MongoDB是一种流行的开源文档数据库,支持主从复制。在MongoDB主从复制中,主服务器将所有写入 *** 作记录到 *** 作日志中,并通过网络将这些 *** 作转发给从服务器进行复制。

Redis:Redis是一种流行的开源内存数据库,支持主从复制。在Redis主从复制中,主服务器将所有写入 *** 作记录到AOF(追加写入文件)中,并通过网络将这些 *** 作转发给从服务器进行复制。

需要注意的是,每种数据库在实现主从部署时可能有不同的设置和配置方式。因此,在进行主从部署时,需要按照数据库的官方文档或相关教程进行 *** 作。

MySQL是一个关系型数据库管理系统,由瑞典MySQL

AB公司开发,目前属于Oracle公司。MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。

以上就是关于linux 怎么部署mysql数据库全部的内容,包括:linux 怎么部署mysql数据库、哪些数据库是主从部署、如何在centos6.5配置mysql 数据库服务器部署等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9524746.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存