在Linux下安装mysql的步骤:

  1.          下载安装文件,百度mysql 下载,找到点击子菜单yum
  2.          安装文件  #wget (下载链接)
  3.          按照mysql上yum的安装程序安装:http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
    1. sudo rpm -Uvh platform-and-version-specific-package-name.rpm
    2. yum repolist all | grep mysql
    3. yum repolist enabled | grep mysql
    4. sudo service mysqld start
    5. sudo service mysqld status
    6. sudo grep 'temporary password' /var/log/mysqld.log                                                                                              i.  这里会出现密码,用在下一步骤使用
  4.            登录mysqlmysql -uroot –p
  5.            设置sql的字符

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '写自己的密码';

Query OK, 0 rows affected (0.00 sec)

 

mysql> SHOW VARIABLES LIKE ‘character%’;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘character%’' at line 1

mysql> show variables like 'character_set_%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client     | utf8                       |

| character_set_connection | utf8                       |

| character_set_database   | latin1                     |

| character_set_filesystem | binary                     |

| character_set_results    | utf8                       |

| character_set_server     | latin1                     |

| character_set_system     | utf8                       |

| character_sets_dir       | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.00 sec)

 

mysql> show variables like 'collation_%';

+----------------------+-------------------+

| Variable_name        | Value             |

+----------------------+-------------------+

| collation_connection | utf8_general_ci   |

| collation_database   | latin1_swedish_ci |

| collation_server     | latin1_swedish_ci |

+----------------------+-------------------+

3 rows in set (0.00 sec)

 

mysql> set character_set_database=utf8;

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> set character_set_server =utf8;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show variables like 'character_set_%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client     | utf8                       |

| character_set_connection | utf8                       |

| character_set_database   | utf8                       |

| character_set_filesystem | binary                     |

| character_set_results    | utf8                       |

| character_set_server     | utf8                       |

| character_set_system     | utf8                       |

| character_sets_dir       | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.00 sec)

 

mysql> show variables like 'collation_%';

+----------------------+-----------------+

| Variable_name        | Value           |

+----------------------+-----------------+

| collation_connection | utf8_general_ci |

| collation_database   | utf8_general_ci |

| collation_server     | utf8_general_ci |

+----------------------+-----------------+

3 rows in set (0.01 sec)

 

6.            创建数据库及表格

7.            在新的数据库里创建数据库及表,如下:

 

先查看旧数据库的表结构

create database ycsmart;

create table userinfo (

id int(11) primary key not null auto_increment,

usname varchar(200) not null ,

uspass varchar(50) not null,

phone varchar(50) not null,

status int(11) not null,

count int(11) not null,

gateid varchar(200) not null,

opened varchar(200)

);

create table gateway (

id int(11) not null primary key  auto_increment,

guser varchar(200) not null ,

gpwd varchar(100) not null,

gateid varchar(200) not null,

createtime varchar(100) not null,

userid int(11) not null,

status int(11),

count int(11)

);

 

 8.            从旧数据库导出数据脚本。

不进入mysql里,输入: mysql  -u root –p ycsmart  -h 101.254.181.162 >new1.sql

例如:mysql  -u yuzi –p ycsmart  -h 101.254.181.162 >new1.sql

 

在新数据库中,导入脚本的方法:

不进入mysql里,输入: mysql  -u root –p ycsmart <new1.sql  回车输入密码完。

 

给指定的用户权限:

mysql> grant select,delete,update,insert on ycsmart.userinfo to 'user';

Query OK, 0 rows affected (0.00 sec)

 

mysql> grant select,delete,update,insert on ycsmart.gateway to 'user';

Query OK, 0 rows affected (0.00 sec)

 

9.            最后就测试完毕。

 

l  其他操作:

设置mysql自动启动:#chkconfig mysqld on

设置tomcat自动启动:omcat开机启动方法二:

 1、把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat.

 #!/bin/bash

 #

 # kenny kenny.zhou@tom.com

 # /etc/rc.d/init.d/tomcat

 # init script for tomcat precesses

 #

 # processname: tomcat

 # description: tomcat is a j2se server

 # chkconfig: 2345 86 16

 # description:  Start up the Tomcat servlet engine.

 if [ -f /etc/init.d/functions ]; then

         . /etc/init.d/functions

 elif [ -f /etc/rc.d/init.d/functions ]; then

         . /etc/rc.d/init.d/functions

 else

         echo -e "\atomcat: unable to locate functions lib. Cannot continue."

         exit -1

 fi

 RETVAL=$?

 CATALINA_HOME="/usr/local/tomcat"

 case "$1" in

 start)

         if [ -f $CATALINA_HOME/bin/startup.sh ];

           then

             echo $"Starting Tomcat"

             $CATALINA_HOME/bin/startup.sh

         fi

         ;;

 stop)

         if [ -f $CATALINA_HOME/bin/shutdown.sh ];

           then

             echo $"Stopping Tomcat"

             $CATALINA_HOME/bin/shutdown.sh

         fi

         ;;

 *)

         echo $"Usage: $0 {start|stop}"

         exit 1

         ;;

 esac

 exit $RETVAL

 #以上为tomcat开机启动的启动脚本代码

 2、将tomcat文件拷贝到/etc/init.d/下,并运行:chkconfig --add tomcat  //这句的意思是添加tomcat服务

 3、在tomcat/bin/catalina.sh文件中加入以下语句:

 export JAVA_HOME=/YOURPATH/tomcat/jdk

 export CATALINA_HOME=/YOURPATH/tomcat

 export CATALINA_BASE=/YOURPATH/tomcat

 export CATALINA_TMPDIR=/YOURPATH/tomcat/temp

 启动tomcat: service tomcat start

 

停止tomcat:  service tomcat stop

 

至此tomcat开机启动全部配置完毕,下次linux重启的时候就会自动启动tomcat了!

 

 

 

 

 


 

 

如果在安装过程期间发生异常:No more mirrors to try

请不停的继续下载,不要上网找其他方法 ,因为我试过没有用。