flyonok

统计

留言簿(8)

ACE

book

boost

bsd

c study

c++

code download

codeblock

computer clound

Eclipse

embed system

erlang

ET++

gtk

ic card

java

KDE

libevent

linux

linux--MM

mysql

network education

one card

oracle

pcap relation

php

powerbuilder

python

QT

software config

software test

SQL server

UML

wireless

wxwidgets

陈宾

阅读排行榜

评论排行榜

how to install mysql on ubuntu

1.sudo apt-get install mysql-server
2.sudo apt-get install php5-mysql

Installing Mysql database in Ubuntu

#apt-get install mysql-server mysql-client libmysqlclient12-dev

MySQL initially only allows connections from the localhost (127.0.0.1). We’ll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf

#vi /etc/mysql/my.cnf

Find the line bind-address = 127.0.0.1 and comment it out

#bind-address = 127.0.0.1

You can check your configuration using the following command

#netstat -tap

Output Looks like below

tcp 0 0 *:mysql *:* LISTEN 4997/mysqld

MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the computer you’re working on. For more information see here

#mysqladmin -u root password your-new-password

#mysqladmin -h root@local-machine-name -u root -p password your-new-password

#/etc/init.d/mysql restart

If you are looking how to create database,tables and other things check here

If you are looking for webinterface administration or GUI tools for your mysql database check here

  1. Lois Says:

    Hi!
    I have installed mysql server on my Ubuntu Desktop; and works fine, but I want to change de mysql datadir. Do yo know how can I change that? If I edit my.conf the line datadir for my directori, mysql never restarts.
    The new datadir is with the same permissions, and content.

    Any ideas? Wy in apache is easy to change but in mysql not?

  2. Admin Says:

    Hi Lois,

    Here is the procedure how to change Mysql default data directory

    By default, MySQL’s datadir is placed in the /var/lib/mysql directory.

    Create the directory that will be new datadir (ex:-/home/db)

    chown the directory to the mysql:mysql user

    sudo chown -R mysql:mysql /home/db/*

    You need to stop the mysql server using the following command

    sudo /etc/init.d/mysql stop

    Now you need to edit the /etc/mysql/my.cnf file

    sudo vi /etc/mysql/my.cnf

    and look for “datadir = /var/lib/mysql” this si where mysql database default data directory here you need to change this one to your new directory

    datadir = /home/db

    copy the files from the old datadir to the new location. However, make sure that the files named
    ib_arch_log_0000000000, ib_logfile0 etc. are not copied to the newer location.

    Make sure that the files and directories are owned by mysql user

    Make changes in the my.cnf to point the new datadir.

    Restart the MySQL database

    sudo /etc/init.d/mysql start

    hope this helps

  3. Lois Says:

    Yeah!!! you’re my hero! my problem was the direcotri privilegies in the new datadir; but that’s it with the chown -R mysql:mysql.
    Do it after copying the files.

    Thanks for all!

  4. 1、安装MySQL
    这个应该很简单了,而且我觉得大家在安装方面也没什么太大问题,所以也就不多说了,下面我们来讲讲配置。
    2、配置MySQL
    注意,在Ubuntu下MySQL缺省是只允许本地访问的,如果你要其他机器也能够访问的话,那么需要改变/etc/mysql/my.cnf配置文件了!下面我们一步步地来:
    默认的MySQL安装之后根用户是没有密码的,所以首先用根用户进入:
    $mysql -u root
    在这里之所以用-u root是因为我现在是一般用户(firehare),如果不加-u root的话,mysql会以为是firehare在登录。注意,我在这里没有进入根用户模式,因为没必要。一般来说,对mysql中的数据库进行操作, 根本没必要进入根用户模式,只有在设置时才有这种可能。
    进入mysql之后,最要紧的就是要设置Mysql中的root用户密码了,否则,Mysql服务无安全可言了。
    mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";
    注意,我这儿用的是123456做为root用户的密码,但是该密码是不安全的,请大家最好使用大小写字母与数字混合的密码,且不少于8位。
    这样的话,就设置好了MySQL中的root用户密码了,然后就用root用户建立你所需要的数据库。我这里就以xoops为例:
    mysql>CREATE DATABASE xoops;
    mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@localhost IDENTIFIED BY "654321";
    这样就建立了一个xoops_roots的用户,它对数据库xoops有着全部权限。以后就用xoops_root来对xoops数据库进行管理,而无需要再用root用户了,而该用户的权限也只被限定在xoops数据库中。
    如果你想进行远程访问或控制,那么你要做两件事:
    其一:
    mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@"%" IDENTIFIED BY "654321";
    允许xoops_root用户可以从任意机器上登入MySQL。
    其二:
    $sudo nano /etc/mysql/my.cnf
    >bind-address = 127.0.0.1 => # bind-address = 127.0.0.1
    这样就可以允许其他机器访问MySQL了。
  5. 如果要开发mysql的C程序 ,用以下命令安装客户端

 sudo apt-get install libmysqlclient15-dev

posted on 2007-12-22 13:37 flyonok 阅读(580) 评论(0)  编辑 收藏 引用 所属分类: mysql


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理