Pipo
Pipo

Reputation: 193

change datadir for MariaDB 5.5

I want to change my datadir for MariaDB. I mean I want to have all my file except data folder in

C:\Program Files\MariaDB

5.5 and my data file in

C:\user\appdata.

I don't want any data file in the first path (even my.ini). When I go in my command line, and execute

C:\Program Files\MariaDB 5.5\bin\mysqld

it doesn't work because I don't have any data folder in this path :

C:\Program Files\MariaDB 5.5.

I know that I have to change datadir in my.ini but the problem is : how can I change the default path to my.ini? I repeat, I don't want any data file in

C:\Program Files\MariaDB 5.5

If I can change this default path, then I will just have to change datadir. Thanks guys for your answers and sorry for my English :)

Upvotes: 9

Views: 14632

Answers (3)

On Windows 7, there's no "service" or "stop" command. To stop MariaDB, select Control Panel > Administrative Tools > Services, scroll down to MySQL, click on it, and click the Stop link on the menu at left. Then do the change to my.ini, then click the Start link.

Upvotes: 0

Minqi Pan
Minqi Pan

Reputation: 2801

I did this in Fedora 20, but in your Windows case things are similar.

  1. Stop MariaDB using the following command:

    service mariadb stop
    

    or (for more recent Fedora versions)

    sudo systemctl stop mariadb
    
  2. Make sure the parent directory of the new data directory has execute permissions.

    namei -mo /path/to/directory
    chmod +x /path/to/parent
    
  3. Copy the existing data directory (default located in /var/lib/mysql) using the following command:

    sudo cp -R -p /var/lib/mysql /newpath
    
  4. Edit the MariaDB configuration file with the following command:

    vim /etc/my.cnf.d/server.cnf
    

    or (for more recent MariaDB versions)

    vim /etc/my.cnf.d/mariadb-server.cnf
    
  5. Look for the entry for datadir, or create one under [mysqld] and change the path (which should be /var/lib/mysql) to the new data directory.

    datadir   = /newpath
    
  6. Restart MySQL with the command:

    service mariadb start
    

    or (for more recent Fedora versions)

    sudo systemctl start mariadb
    

Upvotes: 10

mwelliana
mwelliana

Reputation: 1

Try this from command prompt:

"C:\Program Files\MariaDB 10.1\bin\mysql_install_db.exe" --datadir=d:\your_new_data_dir --service=your_mysql_service --password=your_password

Upvotes: -1

Related Questions