日期:2014-05-16 浏览次数:20805 次
?编译安装 MySQL 5.5.13?
以前没安装过 费了好大力气
编译安装 MySQL 5.5.13 建立mysql安装目录及数据存放目录 # mkdir /usr/local/mysql # mkdir /usr/local/mysql/data # mkdir /usr/local/mysql/etc 创建用户和用户组 # groupadd mysql # useradd -g mysql mysql 赋予数据存放目录权限 # chown mysql:mysql –R /usr/local/mysql/data 通过http://www.mysql.com/downloads/mysql官方网址或国内的sohu镜像下载软件包。 # wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.13.tar.gz # tar zxvf mysql-5.5.13.tar.gz # cd mysql-5.5.13 # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DSYSCONFDIR=/usr/local/mysql/etc \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ -DMYSQL_USER=mysql \ -DEXTRA_CHARSETS=all \ -DWITH_READLINE=1 \ -DWITH_SSL=system \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/usr/local/mysql/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 # make # make install # make # make install 在make与make install的时候可以看到进度百分比,感觉这一点要比configure方式要好。 6.配置并初始化数据库 创建my.cnf配置文件 # mkdir /usr/local/mysql/log # mkdir /usr/local/mysql/etc # cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf 修改my.cnf 添加如下内容: socket = /tmp/mysqld.sock datadir = /usr/local/mysql/data 初始化数据库 执行前需赋给scripts/mysql_install_db文件执行权限 # chmod 755 scripts/mysql_install_db # scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 创建管理MySQL数据库的shell脚本 # mkdir /usr/local/mysql/init.d # cp support-files/mysql.server /usr/local/mysql/init.d/mysql 赋予shell脚本可执行权限: # chmod +x /usr/local/mysql/init.d/mysql 启动MySQL: # /usr/local/mysql/init.d/mysql start 通过命令行登录管理MySQL服务器(提示输入密码时直接回车): # /usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock or # /usr/local/mysql/bin/mysql -u root -p 输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678): GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678'; 为root帐户设置初始密码 # /opt/mysql/bin/mysqladmin -u root password 'new-password' 删除本机匿名连接的空密码帐号 /usr/local/mysql/bin/mysql -uroot -p'new-password' mysql>use mysql; //选择系统数据库mysql mysql>select Host,User,Password from user; //查看所有用户 mysql>delete from user where password=""; mysql>flush privileges; mysql>select Host,User,Password from user; //确认密码为空的用户是否已全部删除 mysql>exit;
?