#tar zxvf mysql-5.0.18.tar.gz
#cd mysql-5.0.18
#./configure --prefix=/usr/local/mysql --with-charset=gb2312 --with-extra-charsets=all #--prefix指定安装目录,让他支持中文,支持所有语
#指定安装路径为/usr/local/mysql,配置文件存放目录/etc,数据库存储目录/var/lib/mysql
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql
(供参考)
#make
#make install
#make clean
#groupadd mysql
#useradd -g mysql mysql (第一个mysql是组,第二个mysql是用户)
#cd /usr/local/mysql
#cp usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf (或cp /root/mysql-5.0.18
/support-files/my-huge.cnf.sh /etc/my.cnf 网络上是写括号内的,但我试了不行#根据自己主机的情况复制my-*.cnf的一个,huge是应用于内存在2G以上的情况。)
#bin/mysql_install_db --user=mysql #建立基本数据库,必须指明为mysql用户,只有这一步才能在usr/local/mysql下出现var目录。出现如下:
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
Unknown suffix '@' used for variable 'port' (value '@MYSQL_TCP_PORT@')
080425 4:38:40 /usr/local/mysql/libexec/mysqld: Error while setting value '@MYSQL_TCP_PORT@' to 'port'
Installation of grant tables failed!
Examine the logs in /usr/local/mysql/var for more information.
You can also try to start the mysqld daemon with:
/usr/local/mysql/libexec/mysqld --skip-grant &
You can use the command line tool
/usr/local/mysql/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/local/mysql/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /usr/local/mysql/var that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/local/mysql/bin/mysqlbug script!
# bin/mysqld_safe --user=mysql & #出现如下提示:
[1] 23095
[root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/var
###这样就停在这边,就是正常启动。如果想确认用下面命令
# ps -aux |grep mysql
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
root 23095 0.1 0.2 4408 1084 pts/1 S 04:44 0:00 /bin/sh bin/mysqld_safe --user=mysql
mysql 23118 3.1 2.4 114464 12676 pts/1 Sl 04:44 0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --pid-file=/usr/local/mysql/var/localhost.localdomain.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
root 23128 0.0 0.1 5524 640 pts/1 R+ 04:44 0:00 grep mysql
###这样表示有mysql进程
#bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.25-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit
Bye ####只有mysql进程,这一步才能执行,因为最初mysql的root密码是空的,所以回车直接就进入。
#bin/mysqladmin -uroot password 123456 (设置mysql的root密码为123456)
#[root@Linux mysql]# bin/mysql -u root -p (用新的密码可以进去,表示设置root密码成功)
Enter password: (输入完新密码后变成如下:)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.25-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
#bin/mysqld_safe &或/usr/local/mysql/share/mysql/mysql.server start 启动mysql
#/usr/local/mysql/share/mysql/mysql.server stop 停止mysql
#ps -aux|grep mysql查看进程
#kill id号 ----这是杀mysql进程的,id号是在查看mysql进程里面看的到。
我们来修改一下mysql的启动的方式,让它以系统守护进程的方式开户服务
#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld 这样下次就可以用/etc/init.d/mysqld start启动了
# bin/mysql -uroot -p
Enter password:
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
这个是mysql没启动
# /etc/init.d/mysqld start (或/usr/local/mysql/mysql/share/mysql.server start这样启动)
# bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.25-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.00 sec)
mysql>
#chkconfig --add mysqld 添加mysql为服务
#chkconfig --del mysqld 删除mysql服务
service mysqld restart #重新启动服务查看是否生效
chkconfig --list mysqld #查看是否345运行级别都打开mysql
完成!以上安装过程同样适用于mysql5的安装
笔者发现mysql5版本在安装后即可直接使用mysql命令进入数据库,而在4版本系列中,mysql路径并没有放入系统环境变量中,输入mysql系统会报找不到这命令的错误,因此笔者擅自修改了环境变量,把mysql的路径添加进环境变量中去。
修改profile文件,将mysql的路径添加到PATH变量中去。
vi /etc/profile
if ! echo $PATH | /bin/egrep -q "(^|: )$1($|: )" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH: $1:/usr/local/mysql/bin
else
PATH=$1: $PATH:/usr/local/mysql/bin
或
编辑/etc/profile文件:
vi /etc/profile
在文件最后添加如下两行:
PATH=$PATH:/usr/local/mysql/bin
export PATH
执行下面的命令使所做的更改生效:
. /etc/profile
分享到:
相关推荐
centos7.0安装mysql centos7.0安装mysql centos7.0安装mysql
### CentOS安装MySQL 5.7知识点详解 #### 一、环境准备与系统要求 在开始安装MySQL 5.7之前,我们需要确保系统满足以下条件: - **操作系统**:CentOS 7.x或更高版本。 - **硬件配置**:至少1GB内存,推荐2GB以上;...
CentOS下MySQL成功安装 MySQL是一种流行的关系数据库管理系统,广泛应用于Web应用程序和企业级应用程序中。在CentOS操作系统中,安装MySQL服务器需要经过一系列的步骤,包括下载、编译、安装、初始化数据库、注册...
CentOS 7 安装 MySQL
### CentOS安装MySQL 5.5知识点详解 #### 1. 概述 本文档旨在指导如何在CentOS系统上从源代码编译、安装并配置MySQL 5.5数据库管理系统。该过程涉及到软件环境的准备、编译工具的安装、MySQL源代码的编译与配置等...
CentOS 6 安装 MySQL 5.6 MySQL 是一个流行的开源关系数据库管理系统,广泛应用于 Web 应用程序中。 CentOS 6 是一个基于 Linux 的操作系统,本文将指导您如何在 CentOS 6 上安装 MySQL 5.6。 关闭 SELinux ...
在本地虚拟机的场合,需要更换yum安装网络地址配置文件CentOS-Base.repo 从阿里云服务器下载一份CentOS-Base.repo文件存到本地
Centos6.7系统安装MySQL5.7总结 本资源总结了在Centos6.7系统中安装MySQL5.7的步骤,包括下载和安装MySQL软件包,创建数据库仓库目录,新建MySQL用户和组,修改目录属有者,配置参数,修改系统配置文件,启动MySQL...
用于在CentOS8中安装mysql8.3.0的安装包
MySQL安装后,建议执行`mysql_secure_installation`脚本来增强安全性: ``` /usr/bin/mysql_secure_installation ``` 在这个脚本中,你可以设置root用户的密码、删除匿名用户、禁止root远程登录以及删除测试数据库。...
### CentOS 7.4 安装 MySQL 5.7 的详细步骤及注意事项 #### 一、安装流程 1. **进入指定目录** 首先,打开终端并进入到 `/usr/local/` 目录下: ```bash cd /usr/local/ ``` 2. **创建工具目录** 接着,...
centos 6.5下安装配置mysql,以及mysql的安全管理和账户管理
根据提供的文件信息,这里将详细解释如何在 CentOS 下安装 MySQL 主从配置的步骤。以下是具体的安装过程: ### 1. 确认 CentOS 版本 确保系统版本为 CentOS 6.3,可以通过命令行输入 `cat /etc/centos-release` 来...
对于Linux系统,尤其是CentOS 7这样的企业级发行版,MySQL的安装和管理至关重要。本文将详细讲解如何在CentOS 7上离线进行MySQL8的一键自动安装。 首先,离线安装意味着我们需要提前下载MySQL8的安装包,并通过本地...
centos7.9 自动安装mysql8.0.33,附带脚本
MySQL安装后,需要进行一些安全配置,如设置root用户的密码,删除匿名用户等,运行`sudo mysql_secure_installation`。 四、连接MySQL 1. 首次安装后,root用户没有密码。可以使用`sudo mysql -u root`进入MySQL...
在本教程中,我们将深入探讨如何在CentOS7操作系统上安装MySQL 5.7.19并设置主从复制配置。MySQL的主从复制是一种常用的技术,它允许数据从一个服务器(主服务器)同步到另一个服务器(从服务器),从而实现数据备份...
CentOS 7.6 安装 MySQL 5.7 MySQL 是一个开源的关系数据库管理系统,广泛应用于 web 开发中。下面是 CentOS 7.6 安装 MySQL 5.7 的步骤。 安装 MySQL 首先,需要新建文件夹 `/opt/mysql` 并 cd 进去。然后,下载...
1. **检查MySQL安装情况**: ``` [root@xiaoluo ~]# rpm -qa | grep mysql ``` 如果返回结果为空,则表示系统未安装MySQL;如果有返回结果,则表示已安装MySQL。 2. **卸载MySQL**: - 普通卸载模式: ``` ...
centos 安装mysql5.7 Linux下centos安装mysql5.7 超详细步骤,带你手把手安装mysql