#!/bin/sh # # Copyright (C) 2004 MySQL AB # For a more info consult the file COPYRIGHT distributed with this file. # # This script converts any old privilege tables to privilege tables suitable # for MySQL 4.0. # # You can safely ignore all 'Duplicate column' and 'Unknown column' errors" # as this just means that your tables where already up to date. # This script is safe to run even if your tables are already up to date! # # On windows you should do 'mysql --force < mysql_fix_privilege_tables.sql' # instead of this script # # Usage: # mysql_fix_privilege_tables # - fix tables for host "localhost" as "root" with no password # mysql_fix_privilege_tables # - fix tables for host "localhost" as "root" with # mysql_fix_privilege_tables --sql-only # - output sql-script to file /usr/share/mysql/echo_stderr # mysql_fix_privilege_tables OPTIONS # - fix tables on connection with OPTIONS # # where OPTIONS are # --host= # --port= # --socket= # --user= # --password= # --database= root_password="$1" host="localhost" user="root" port="" socket="" comment="" database="mysql" # read all the options parse_arguments() { for arg do case "$arg" in --sql-only) cmd="/usr/share/mysql/echo_stderr" ;; --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;; --user=*) user=`echo "$arg" | sed -e "s;--user=;;"` ;; --host=*) host=`echo "$arg" | sed -e "s;--host=;;"` ;; --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; --password=*) root_password=`echo "$arg" | sed -e "s;--password=;;"` ;; --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;; *) echo "Unknown argument '$arg'" exit 1 ;; esac done } parse_arguments "$@" if test -z "$cmd"; then cmd="@bindir@/mysql -f --user=$user --host=$host" if test ! -z "$root_password"; then cmd="$cmd --password=$root_password" fi if test ! -z "$port"; then cmd="$cmd --port=$port" fi if test ! -z "$socket"; then cmd="$cmd --socket=$socket" fi cmd="$cmd $database" fi echo "This scripts updates the mysql.user, mysql.db, mysql.host and the" echo "mysql.func tables to MySQL 3.22.14 and above." echo "" echo "This is needed if you want to use the new GRANT functions," echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 3.23" echo "" echo "If you get 'Access denied' errors, you should run this script again" echo "and give the MySQL root user password as an argument!" echo "Converting all privilege tables to MyISAM format" $cmd < Grant # and Create -> Alter, Index, References if test $res = 0 then echo "Setting default privileges for the new grant, index and alter privileges" $cmd < Column_priv from MySQL 3.22.12 # echo "Changing name of columns_priv.Type -> columns_priv.Column_priv" echo "You can ignore any Unknown column errors from this" $cmd <""; END_OF_DATA echo "" fi # Add fields that can be used to limit number of questions and connections # for some users. $cmd <