linux二进制安装mysql,以及使用/etc/init.d/mysqld启动mysql出现的错误和解决方法

源码包下载

二进制​(i686是32位操作系统 x86_64 是64位操作系统)


                                            linux二进制安装mysql,以及使用/etc/init.d/mysqld启动mysql出现的错误和解决方法

可以​右击复制链接地址,在服务器上面wget


                                            linux二进制安装mysql,以及使用/etc/init.d/mysqld启动mysql出现的错误和解决方法

二进制的安装步骤

1.​上传压缩包并解压

[root@localhost ~]# tar xf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz

2.​创建msyql安装目录

[root@localhost ~]# mkdir /lm

3oracle怎么读.​移动mysql程序linux重启命令到安装目录

[root@localhost ~]# mv mysql-5.6.10-linux-glibc2.5-x86_64 /lm/mysql-5.6.10

4oracle怎么读.创建​软连接

cd 到软连接里面 cd support-files 拷贝脚本

覆盖系统文件myoracle安装.cnf

cp my-default.cnf /etc/my.cnf

覆盖启动脚本

cp mysql.server /etc/init.d/mysqld

[root@localhost mysql]# ln -s /lm/mysql-5.6.10 /lm/mysql
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ll
total 32
-rwxr-xr-x. 1 7161 wheel 1153 Jan 23 2013 binary-configure
-rw-r--r--. 1 7161 wheel 773 Jan 23 2013 magic
-rw-r--r--. 1 7161 wheel 1126 Jan 23 2013 my-default.cnf
-rwxr-xr-x. 1 7161 wheel 1061 Jan 23 2013 mysqld_multi.server
-rwxr-xr-x. 1 7161 wheel 894 Jan 23 2013 mysql-log-rotate
-rwxr-xr-x. 1 7161 wheel 10650 Jan 23 2013 mysql.server
drwxr-xr-x. 2 root root 33 Mar 28 12:44 solaris
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld

初始化

oracle分页查询进入初始化目mysql数据库基础知识

cd mysql/scripts

创建mysql色多多导入用户

[root@localhost scripts]# useradd mysql -s /sbin/nologin -M

安装初始化依赖

cd /lm/mysql/scripts
yum install -y autoconf
./mysql_install_db --user=mysql --basedir=/lm/mysql --datadir=/lm/mysql/data/

启动mysqld

[root@localhost bin]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!

添加环境变量

[root@localhost lm]# cat /etc/profile.d/mysql.sh
export PATH="/lm/mysql/bin:$PATH"

进入mysql,查mysql面试题看mysql用户

[root@localhost lm]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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> select user,host from mysql.user;
+------+-----------------------+
| user | host |
+------+-----------------------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+
6 rows in set (0.00 sec)

mysql>

启动mysql报错1:

[root@localhost bin]# /etc/init.d/mysqld start
/etc/init.d/mysqld: line 256: /usr/local/mysql/bin/my_print_defaults: Permission denied
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

原因:

编辑/etc/my.cnf 文件,因为缺少basedir 和datadir 两个路径,在 [mysqld]添加上即可

解决方法

[mysqld]
……
basedir=/lm/mysql
datadir=/lm/mysql/data

[root@localhost bin]# /etc/init.d/mysqld start

Starting MySQL. SUCCESS!

或者 更改目录


                                            linux二进制安装mysql,以及使用/etc/init.d/mysqld启动mysql出现的错误和解决方法

mysql 报错2:

提示没有目录 就创建目录

提示没有权限 就赋予mysql用户权限

chown -R mysql.mysql /lm/mysql*