#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

本文出自 “小客” 博客,请务必保留此出处http://peiyan.blog.51cto.com/344889/240999

linux下安装MYSQL详细配置(转)的更多相关文章

  1. linux下安装mysql详细步骤

    最近买了个阿里云服务器,搭建mysql环境. 该笔记用于系统上未装过mysql的干净系统第一次安装mysql.自己指定安装目录,指定数据文件目录. linux系统版本: CentOS 7.3 64位 ...

  2. linux 下安装 mysql 并配置 python 开发环境

    1.安装 mysql ,安装过程中将提示设置 root 用户的密码,默认可以设置为 rootadmin . $ sudo apt-get install mysql-server 2.安装 mysql ...

  3. 【云服务器部署】---Linux下安装MySQL

    [云服务器部署]---Linux下安装MySQL 有关如何阿里云ECS建网站,推荐一片文章,我是是通过这篇文章安装tomcat和jdk的 网址:阿里云ECS建网站(建站)超详细全套完整图文教程! 注意 ...

  4. Windows下安装MySQL详细教程

    Windows下安装MySQL详细教程 1.安装包下载  2.安装教程 (1)配置环境变量 (2)生成data文件 (3)安装MySQL (4)启动服务 (5)登录MySQL (6)查询用户密码 (7 ...

  5. Linux下安装mysql(2) 及常见问题解决(CentOS)

    上一篇讲了基本的安装,这篇姑且算作进阶吧 链接Linux下安装mysql(1) 1.准备好mysql的rpm安装包 2.解压并进入usr/local/mysql 3.先执行useradd mysql( ...

  6. Linux下安装mysql(1)(CentOS)

    标题是(1)也就是说这次是基础安装,这种方式安装,没有组的创建,权限管理,配置文件更改等,仅仅是最基本的安装,适合第一次在linux上安装mysql的新手 1.准备好安装包(Linux-Generic ...

  7. Linux下安装mysql教程

    Linux下安装mysql  MySQL官网:https://dev.mysql.com/downloads/mysql/ 到mysql官网下载mysql编译好的二进制安装包,在下载页面Select ...

  8. linux 下安装jdk及配置jdk环境图解

    linux 下安装jdk及配置jdk环境图解 一:先检測是否已安装了JDK 运行命令: # rpm -qa|grep jdk  或   # rpm -q jdk  或  #find / -name j ...

  9. Linux 下安装mysql 5.7

    Linux 下安装mysql 5.7 本人首次安装时按照菜鸟教程的步骤一步一步来的,结果意外的是 装成5.6了,而且各种无厘头的问题,例如无法启动... 本文参照 大佬:‘这个名字想了很久~’ 的&l ...

随机推荐

  1. P2471 [SCOI2007]降雨量

    Description 我们常常会说这样的话:"X年是自Y年以来降雨量最多的".它的含义是X年的降雨量不超过Y年,且对于任意Y<Z<X,Z年的降雨量严格小于X年.例如2 ...

  2. jersey 过滤器名称绑定的问题 NameBinding Provider

    查资料也不容易查,这个问题困扰了我两天. 当没有 @Provider 的时候 过滤器不会被执行.

  3. 20165203《Java程序设计》第三周学习总结

    教材学习内容总结 1.类: (1)类的声明:class+类名 (2)类体:成员变量的声明+方法(局部变量+语句) 注意: 方法体内声明的局部变量只在方法内有效和书写位置有关. 局部变量和成员变量同名: ...

  4. CCF CSP 201609-4 交通规划

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201609-4 交通规划 问题描述 G国国王来中国参观后,被中国的高速铁路深深的震撼,决定为自 ...

  5. Java学习(异常类练习题)

     练习题: 1.计算圆的面积,半径不能为零和负数 package com.oracle.Demo01; public class Demo02 { // 写一个计算圆的面积的方法,传一个半径,返回面积 ...

  6. HBase(二)CentOS7.5搭建HBase1.2.6HA集群

    一.安装前提 1.HBase 依赖于 HDFS 做底层的数据存储 2.HBase 依赖于 MapReduce 做数据计算 3.HBase 依赖于 ZooKeeper 做服务协调 4.HBase源码是j ...

  7. USACO 6.5 All Latin Squares

    All Latin Squares A square arrangement of numbers 1 2 3 4 5 2 1 4 5 3 3 4 5 1 2 4 5 2 3 1 5 3 1 2 4 ...

  8. HashMap 在 Java1.7 与 1.8 中的区别

    hashMap 数据结构 如上图所示,JDK7之前hashmap又叫散列链表:基于一个数组以及多个链表的实现,hash值冲突的时候,就将对应节点以链表的形式存储. JDK8中,当同一个hash值(Ta ...

  9. Bechmarksql

    使用方法 1.配置JDK环境 JDK最好是1.5以上的版本 JAVA_HOME=/usr/java/jdk1.6.0_22 PATH=$PATH:$JAVA_HOME/bin 2.准备工作 把要测试的 ...

  10. ECSHOP的JS文件代入问题

    参考一下默认的js写法就行了<script type='text/javascript' src='themes/ecmoban/js/jquery-1.7.2.min.js'></ ...