Mysql linux安装日志
bailian
|
1#
bailian 发表于 2008-03-12 00:21
Mysql linux安装日志
1.Add a login user and group for `mysqld' to run as:为‘mysqld’增添一个登陆用户和组
shell> groupadd mysql shell> useradd -g mysql mysql 2.解压 shell> gunzip < mysql-5.0.15.tar.gz | tar -xvf - shell> cd mysql-5.0.15 3.Configure the release and compile everything:配置和编译给configure分配可执行文件 shell> chmod +x configure 改变字符集为 GBK [默认字符集为ISO-8859-1(Latin1)] shell> ./configure --prefix=/usr/local/mysql --with-charset=gbk shell> make (字符集还有big5、cp1251、cp1257、czech、danish、dec8、dos、euc_kr、gb2312 gbk、german1、hebrew、 hp8、hungarian、koi8_ru、koi8_ukr、latin1、latin2、sjis、swe7、tis620、ujis、usa7、win1251或win1251ukr) 4.安装所有东西 shell> make install 5.如果你想安装选项文件,使用当前存在的‘support-files’ 文件夹下的作为模板,例如: shell> cp support-files/my-medium.cnf /etc/my.cnf 6.如果想mysqld每次开机自动启动的话。cp -r support-files/mysql.server /etc/init.d/就行了 shell> cp -r support-files/mysql.server /etc/init.d/mysql shell> cd /etc/rc.d/init.d shell> chmod +x mysql shell> /sbin/chkconfig --del mysql shell> /sbin/chkconfig --add mysql 7.进入安装目录 shell> cd /usr/local/mysql 8.如果你以前没有安装过MySQL,你必须创建一个MySQL准许的表 shell> bin/mysql_install_db --user=mysql 9.将程序的所有权限给‘root’ ,并且把数据目录的所有权给可以运行‘mysqld’的用户。假设MySQL的安装目录是(‘/usr/local/mysql’),命令如下所示: 把文件拥有权给‘root’ shell> chown -R root . 把数据目录拥护权给‘mysql’用户 shell> chown -R mysql var 把组的权限给'mysql'组 shell> chgrp -R mysql . 10.万事具备后,你就可以按照下面的命令测试并运行你的MySQL了: shell> /usr/local/mysql/bin/mysqld_safe --user=mysql & shell> service mysql start 11.在一切正常后,要做的第一件事情是更改管理员的密码。你可以运行mysqladmin (请注意,此命令不一定在你的path中,所以最好是转到此命令的目录中直接执行): shell> cd bin shell> ./mysqladmin -u root password ********* 12.运行其他用户访问本机: shell> ./mysql -u root -p mysql --------------------这里输入你刚才修改的管理员密码 mysql> update user set host='' where host='localhost' and user='root'; mysql> exit Bye 13.修改mysql数据库端口号 shell> vi /etc/my.cnf --------------------修改里面的 port=**** 为你需要的端口号 14.重启应用 shell> service mysql restart MySQL 5 on Linux手动安装方法 1. 下载"mysql-standard-5.0.27-linux-i686-icc-glibc23.tar.gz",推荐ICC版本,据称比GCC性能提高10-20% 2. 复制到/usr/local/,解压:tar zxvf mysql-standard-5.x....tar.gz 3. 添加用户和组mysql: groupadd mysql useradd -g mysql mysql <iframe width="336" scrolling="no" height="280" frameborder="0" allowtransparency="true" hspace="0" vspace="0" marginheight="0" marginwidth="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1572879403720716&dt=1205115559734&hl=zh-CN&lmt=1202872325&alternate_ad_url=http%3A%2F%2Fwww.pcdog.com%2Fjs%2F336.htm&prev_fmts=468x15_0ads_al_s&format=336x280_as&output=html&correlator=1205115559593&channel=2957605308&url=http%3A%2F%2Fwww.pcdog.com%2Fedu%2Fmysql%2F20%2F11%2Fz244118.html&color_bg=F5FAFA&color_text=000000&color_link=1F3A87&color_url=0000FF&color_border=F5FAFA&ad_type=text_image&ref=http%3A%2F%2Fwww.pcdog.com%2Fspecial%2F1359%2F01%2F&frm=0&cc=100&ga_vid=72474345.1205115560&ga_sid=1205115560&ga_hid=1017471773&flash=9.0.115&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=1&u_java=true&u_nplug=8&u_nmime=17" name="google_ads_frame"> 4. 创建符号连接:/usr/local # ln -s mysql-standard-5.x... mysql 5. cd mysql,当前目录改为/usr/local/mysql/ 6. 运行脚步初始化数据库:./scripts/mysql_install_db --user=mysql 7. 设置权限: /usr/local/mysql # chown -R root . /usr/local/mysql # chown -R mysql data /usr/local/mysql # chgrp -R mysql 8. 根据需要创建并修改/etc/my.cnf,参考配置: [mysqld] # 设置默认为INNODB表,支持事务: default-storage-engine=INNODB # 设置默认的字符集: default-character-set=utf8 # 禁用bdb: http://www.knowsky.com skip-bdb 9. 启动MySQL: /usr/local/mysql/bin # ./mysqld_safe --user=mysql & 10. 初始化root口令: /usr/local/mysql/bin # ./mysqladmin -u root -p password "password-of-root" Enter password: <输入旧口令,直接按Enter> 11. 以root登录创建数据库: /usr/local/mysql # ./mysql -u root -p Enter password: password-of-root 创建一个新用户: mysql> create user test identified by 'test-password'; 创建一个新数据库: mysql> create database testdb; 赋予test用户从localhost访问testdb的权限: mysql> grant all on testdb.* to test@localhost; 停止MySQL服务器: /usr/local/mysql/bin # ./mysqladmin -u root -p shutdown Enter password: password-of-root STOPPING server from pid file /usr/local/mysql/data/debian.pid xxx mysqld ended |