MYSQL编译安装:参考(http://v.youku.com/v_show/id_XMjc4MDUwNjYyOA==.html?from=s1.8-1-1.2&spm=a2h0k.8191407.0.0)(http://oldboy.blog.51cto.com/2561410/1917295)
编译安装mysql,最好是系统本身没有安装mysql的痕迹,我的因为是最小化安装,没有任何mysql的安装痕迹。
安装准备:镜像下载:mirrors.sohu.com/mysql/mysql-5.5,因linux环境下wget命令 可能无法下载可以windows下下载,通过rzsz工具上传
创建用户:useradd -s /sbin/nologin -M mysq
安装目录:这里是basedir=/usr/local/mysql,这里做mysql用户的授权chown -R mysql.mysql /usr/local/mysql,数据目录:datadir=/data/mysql/data
依赖文件:yum install gcc gcc-c++ bison ncurses cmake lrzsz
下载后解压:cd /mysql-5.5.54 cmake make make instsall(Could NOT find Threads (missing: Threads_FOUND) 若出现括号里面的内容时,删除CMakeCache。txt文件
cmake的参数:cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data\
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DWITH_EXTRA_CHARSETS=all\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_FEDERATED_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\
-DWITH_ZLIB=bundled\
-DWITH_SSL=bundled\
-DENABLED_LOCAL_INFILE=1\
-DWITH_EMBEDDED_SERVER=1\
-DENABLE_DOWNLOADS=1\
-DWITH_DEBUG=0
编译安装之后:将support-files下的my-large.cnf复制到/etc/my.cnf,mysql.server复制到/etc/init.d/mysqld,并赋予权限
chmod a+x /etc/init.d/mysqld ,设置mysql开机启动,chkconfig –level 345 mysqld
数据库初始化:在/usr/local/mysql/scripts目录下执行./mysql_install_db –user=mysql –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/data
最后将mysql的命令加入全局变量echo “export PATH=/application/mysql/bin:$PATH” >>/etc/profile,source
此时可以用命令登录: /usr/local/mysql/bin/mysqladmin -u root password ‘123456’
弱登陆报错则参考:1.停止mysql数据库
/etc/init.d/mysqld stop
#2.执行如下命令
mysqld_safe –user=mysql –skip-grant-tables –skip-networking &
#3.使用root登录mysql数据库
mysql -u root mysql
#4.更新root密码
mysql> UPDATE user SET Password=PASSWORD(‘newpassword’) where USER=’root’;
#最新版MySQL请采用如下SQL:
mysql> UPDATE user SET authentication_string=PASSWORD(‘newpassword’) where USER=’root’;
#5.刷新权限
mysql> FLUSH PRIVILEGES;
#6.退出mysql
mysql> quit
#7.重启mysql
/etc/init.d/mysqld restart
#8.使用root用户重新登录mysql
mysql -uroot -p
Enter password: <输入新设的密码newpassword>
原创文章,作者:919022966,如若转载,请注明出处:http://www.178linux.com/77798