搞定linux上MySQL编程(一):linux上源码安装MySQL
2015-06-13 17:12
645 查看
【版权声明:尊重原创,转载请保留出处:blog.csdn.net/shallnet,文章仅供学习交流,请勿用于商业用途】
1. 首先下载源码包:
2. 使用如下命令检查系统中是否已安装mysql:
3.没有安装则解压安装包然后进入该目录:
分别依次执行如下操作:
4.添加MySQL配置文件
如果你想要设置一个选项文件,使用support-files目录中的一个作为模板。在这个目录中有4个模板文件,是根据不同机器的内存定制的。
5.设置开机自动启动
6.创建mysql权限表:
7.最后将安装目录的拥有者和所属组分别变更为root和mysql, 命令为:
8.测试成功否?
第一次运行会弹出如下信息,说明安装成功:
9.查看3306端口是否启动:
10.为了安全,需要修改密码,默认为空:
至此,可以在命令行上面使用新的密码登录mysql了。
1. 首先下载源码包:
ftp://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.1/mysql-5.1.72.tar.gz
2. 使用如下命令检查系统中是否已安装mysql:
rpm -qa | grep mysql
3.没有安装则解压安装包然后进入该目录:
cd mysql
分别依次执行如下操作:
./configure --prefix=/usr/local/mysql --with-charset=gbk make make install
4.添加MySQL配置文件
如果你想要设置一个选项文件,使用support-files目录中的一个作为模板。在这个目录中有4个模板文件,是根据不同机器的内存定制的。
#cp support-files/my-medium.cnf /etc/my.cnf
5.设置开机自动启动
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld #chmod 755 /etc/init.d/mysqld #chkconfig –-add mysqld #chkconfig –-level 345 mysqld on
6.创建mysql权限表:
cd /usr/local/mysql scripts/mysql_install_db --user=mysql
7.最后将安装目录的拥有者和所属组分别变更为root和mysql, 命令为:
chown -R root chgrp -R mysql
8.测试成功否?
第一次运行会弹出如下信息,说明安装成功:
#/etc/rc.d/init.d/mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ]
9.查看3306端口是否启动:
# netstat -altnp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:<strong>3306 </strong> 0.0.0.0:* LISTEN 6946/mysqld tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1892/rpcbind tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2726/dnsmasq
10.为了安全,需要修改密码,默认为空:
mysqladmin -u root password shallnet
至此,可以在命令行上面使用新的密码登录mysql了。
相关文章推荐
- 从源码安装Mysql/Percona 5.5
- asp.net 抓取网页源码三种实现方法
- JS小游戏之仙剑翻牌源码详解
- JS小游戏之宇宙战机源码详解
- jQuery源码分析之jQuery中的循环技巧详解
- 本人自用的global.js库源码分享
- java中原码、反码与补码的问题分析
- PHP网页游戏学习之Xnova(ogame)源码解读(六)
- C#获取网页HTML源码实例
- PHP网页游戏学习之Xnova(ogame)源码解读(八)
- PHP网页游戏学习之Xnova(ogame)源码解读(四)
- JS小游戏之极速快跑源码详解
- JS小游戏之象棋暗棋源码详解
- 基于Android设计模式之--SDK源码之策略模式的详解
- Android游戏源码分享之2048
- C语言借助EasyX实现的生命游戏源码
- C实现的非阻塞方式命令行端口扫描器源码
- PHP网页游戏学习之Xnova(ogame)源码解读(七)
- PHP网页游戏学习之Xnova(ogame)源码解读(一)
- PHP网页游戏学习之Xnova(ogame)源码解读(九)