Where does mysql store data?

后端 未结 5 1233
情歌与酒
情歌与酒 2020-12-24 01:08

Where does mysql store data? I found out (by using mysql>SELECT @@datadir ) that it\'s in var/lib/mysql - but that can\'t be it. I have a quite big database (4 GB) called \'

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 01:30

    From here:

    Windows

    1. Locate the my.ini, which store in the MySQL installation folder.

    For Example, C:\Program Files\MySQL\MySQL Server 5.1\my.ini

    1. Open the “my.ini” with our favor text editor.
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="C:/Program Files/MySQL/MySQL Server 5.1/"
     
    #Path to the database root
    datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"
    

    Find the “datadir”, this is the where does MySQL stored the data in Windows.


    Linux

    1. Locate the my.cnf with the find / -name my.cnf command.
    yongmo@myserver:~$ find / -name my.cnf
    find: /home/lost+found: Permission denied
    find: /lost+found: Permission denied
    /etc/mysql/my.cnf
    
    1. View the my.cnf file like this: cat /etc/mysql/my.cnf
    yongmo@myserver:~$ cat /etc/mysql/my.cnf
    #
    # The MySQL database server configuration file.
    #
    # You can copy this to one of:
    # - "/etc/mysql/my.cnf" to set global options,
    # - "~/.my.cnf" to set user-specific options.
    # 
    [mysqld]
    #
    # * Basic Settings
    #
    user   = mysql
    pid-file = /var/run/mysqld/mysqld.pid
    socket  = /var/run/mysqld/mysqld.sock
    port   = 3306
    basedir  = /usr
    datadir  = /var/lib/mysql
    tmpdir  = /tmp
    language = /usr/share/mysql/english
    skip-external-locking
    
    1. Find the “datadir”, this is where does MySQL stored the data in Linux system.

提交回复
热议问题